Commit 6858f40f authored by fengruiyu's avatar fengruiyu

修改 首页的推荐的功能

js交互问题
parent ba364355
...@@ -94,7 +94,7 @@ function tosh(center) { ...@@ -94,7 +94,7 @@ function tosh(center) {
], ],
[ [
"zh-CN", "zh-CN",
"CN", "US",
null, null,
0, 0,
null, null,
......
...@@ -95,8 +95,26 @@ var CoordinateUtil = { ...@@ -95,8 +95,26 @@ var CoordinateUtil = {
return doubles_wgs84; return doubles_wgs84;
}, },
wgs84_to_bd:function(point){ wgs84_to_bd:function(point){
var lng=point.lng;
if(lng>180){
console.log("lng>>",lng)
lng=lng%360;
if(lng>180){
lng=lng-360;
}
console.log("lng>>>>",lng)
}
if(lng<-180){
console.log("lng>>",lng)
lng=lng%360;
if(lng<-180){
lng=lng+360;
}
console.log("lng>>>>",lng)
}
//先转 国测局坐标 //先转 国测局坐标
var doubles_gcj = CoordinateUtil.wgs84togcj02(point.lng, point.lat); //(x 117. y 36. ) var doubles_gcj = CoordinateUtil.wgs84togcj02(lng, point.lat); //(x 117. y 36. )
//国测局坐标转bd //国测局坐标转bd
var doubles_bd = CoordinateUtil.gcj02tobd09(doubles_gcj.lng, doubles_gcj.lat); var doubles_bd = CoordinateUtil.gcj02tobd09(doubles_gcj.lng, doubles_gcj.lat);
//返回 纠偏后 坐标 //返回 纠偏后 坐标
......
...@@ -103,7 +103,7 @@ ...@@ -103,7 +103,7 @@
// panorama.setPov({heading: -40, pitch: 6}); // panorama.setPov({heading: -40, pitch: 6});
// }); // });
map.addEventListener('dragging',function(e){ map.addEventListener('dragging',function(e){
// console.log(map.getCenter()) // console.log(map.getCenter())
marker.setPosition(map.getCenter()); marker.setPosition(map.getCenter());
}); });
map.addEventListener('dragend',function(e){ map.addEventListener('dragend',function(e){
......
This diff is collapsed.
...@@ -126,6 +126,7 @@ class HistoryRecordItemVHM(val activity: SearchMapActivity,val viewModel: Search ...@@ -126,6 +126,7 @@ class HistoryRecordItemVHM(val activity: SearchMapActivity,val viewModel: Search
val intent = Intent() val intent = Intent()
intent.putExtra("latitude",historyBean.latitude) intent.putExtra("latitude",historyBean.latitude)
intent.putExtra("longitude",historyBean.longitude) intent.putExtra("longitude",historyBean.longitude)
intent.putExtra("inner",viewModel.index.value)
viewModel.finishData(SearchMapActivity.REQUEST_CODE,intent) viewModel.finishData(SearchMapActivity.REQUEST_CODE,intent)
}) })
} }
\ No newline at end of file
...@@ -16,8 +16,15 @@ public class GPS { ...@@ -16,8 +16,15 @@ public class GPS {
private @Nullable double lng; private @Nullable double lng;
private @Nullable int inner=0;
public GPS() { public GPS() {
}
public GPS(double lat, double lng,int inner) {
this.lat = lat;
this.lng = lng;
this.inner = inner;
} }
public GPS(double lat, double lng) { public GPS(double lat, double lng) {
this.lat = lat; this.lat = lat;
...@@ -41,6 +48,6 @@ public class GPS { ...@@ -41,6 +48,6 @@ public class GPS {
} }
public String toString() { public String toString() {
return "lat:" + lat + "," + "lng:" + lng; return "lat:" + lat + "," + "lng:" + lng+"," + "inner:" + inner;
} }
} }
\ No newline at end of file
...@@ -8,6 +8,5 @@ class MutualBean { ...@@ -8,6 +8,5 @@ class MutualBean {
var d:String?=null var d:String?=null
var lat:String?=null var lat:String?=null
var lng:String?=null var lng:String?=null
var blat:String?=null var inner:Int=0
var blng:String?=null
} }
\ No newline at end of file
package com.mints.street.main.googlemap package com.mints.street.main.googlemap
import android.os.Bundle import android.os.Bundle
import android.os.Handler
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
...@@ -41,13 +42,14 @@ class GoogleMapFragment() : BaseFragment<ActivityGoogleMapBinding, HomeViewModel ...@@ -41,13 +42,14 @@ class GoogleMapFragment() : BaseFragment<ActivityGoogleMapBinding, HomeViewModel
var mLocationClient: LocationClient? = null var mLocationClient: LocationClient? = null
private val myListener: MyLocationListener = MyLocationListener() private val myListener: MyLocationListener = MyLocationListener()
private var isScrollLayoutClose: Boolean = false
private var gps = GPS() private var gps = GPS(39.915121, 116.403947,0)
inner class MyLocationListener : BDLocationListener { inner class MyLocationListener : BDLocationListener {
override fun onReceiveLocation(location: BDLocation?) { override fun onReceiveLocation(location: BDLocation?) {
gps.lat = location?.latitude?:0.0 gps.lat = location?.latitude?:39.915121
gps.lng = location?.longitude?:0.0 gps.lng = location?.longitude?:116.403947
} }
} }
...@@ -68,6 +70,8 @@ class GoogleMapFragment() : BaseFragment<ActivityGoogleMapBinding, HomeViewModel ...@@ -68,6 +70,8 @@ class GoogleMapFragment() : BaseFragment<ActivityGoogleMapBinding, HomeViewModel
override fun initData() { override fun initData() {
super.initData() super.initData()
Handler().postDelayed({ isScrollLayoutClose = true }, 2000)
binding.webview.setDefaultHandler(DefaultHandler()) binding.webview.setDefaultHandler(DefaultHandler())
binding.webview.webChromeClient = WebChromeClient() binding.webview.webChromeClient = WebChromeClient()
binding.webview.setOnLongClickListener { true } binding.webview.setOnLongClickListener { true }
...@@ -125,8 +129,10 @@ class GoogleMapFragment() : BaseFragment<ActivityGoogleMapBinding, HomeViewModel ...@@ -125,8 +129,10 @@ class GoogleMapFragment() : BaseFragment<ActivityGoogleMapBinding, HomeViewModel
//地图改变时 //地图改变时
binding.webview.registerHandler("centerChanged") { data, _ -> binding.webview.registerHandler("centerChanged") { data, _ ->
KLog.a("js - > android centerChanged", data) KLog.a("js - > android centerChanged", data)
if (!binding.scrollLayout.isClose){ if (!binding.scrollLayout.isClose && isScrollLayoutClose) {
binding.scrollLayout.toggle(STATUS_CLOSE) binding.scrollLayout.post {
binding.scrollLayout.toggle(ScrollLayout.STATUS_CLOSE)
}
} }
} }
//加载完成 //加载完成
...@@ -164,14 +170,8 @@ class GoogleMapFragment() : BaseFragment<ActivityGoogleMapBinding, HomeViewModel ...@@ -164,14 +170,8 @@ class GoogleMapFragment() : BaseFragment<ActivityGoogleMapBinding, HomeViewModel
* 调用JS * 调用JS
*/ */
private fun initZsMap() { private fun initZsMap() {
val bd09ToGcj02 = GPSConverterUtils.bd09_To_Gcj02(gps.lat, gps.lat)
val mutualBean = MutualBean()
mutualBean.lat = bd09ToGcj02.lat.toString()
mutualBean.lng = bd09ToGcj02.lng.toString()
mutualBean.blat = gps.lat.toString()
mutualBean.blng = gps.lng.toString()
binding.webview.callHandler("initZsMap" binding.webview.callHandler("initZsMap"
,Gson().toJson(mutualBean) ) { ,Gson().toJson(gps) ) {
} }
} }
...@@ -232,12 +232,7 @@ class GoogleMapFragment() : BaseFragment<ActivityGoogleMapBinding, HomeViewModel ...@@ -232,12 +232,7 @@ class GoogleMapFragment() : BaseFragment<ActivityGoogleMapBinding, HomeViewModel
} }
}) })
viewModel.pt.observe(this, Observer { viewModel.pt.observe(this, Observer {
val bd09ToGcj02 = GPSConverterUtils.bd09_To_Gcj02(it.lat, it.lat) KLog.a("GPSConverterUtils.bd09_To_Gcj02", Gson().toJson(it))
val mutualBean = MutualBean()
mutualBean.lat = bd09ToGcj02.lat.toString()
mutualBean.lng =bd09ToGcj02.lng.toString()
mutualBean.blat = it.lat.toString()
mutualBean.blng = it.lng.toString()
binding.webview.callHandler("initZsMap" binding.webview.callHandler("initZsMap"
,Gson().toJson(it) ) { ,Gson().toJson(it) ) {
} }
......
...@@ -61,18 +61,11 @@ class HomeViewModel(application: Application) : BaseViewModel(application) { ...@@ -61,18 +61,11 @@ class HomeViewModel(application: Application) : BaseViewModel(application) {
this@HomeViewModel, false this@HomeViewModel, false
) { ) {
override fun onBusinessSuccess(response: BaseResponse<AuthorizedBean>) { override fun onBusinessSuccess(response: BaseResponse<AuthorizedBean>) {
if (!Gson().toJson(response.result)
.equals(Gson().toJson(authorizedBean.value))
) {
authorizedBean.value = response.result
}
MintsWebViewActivity.startWebView( MintsWebViewActivity.startWebView(
name, name,
MintsWebViewActivity.toBaduVR(lat, lng, response.result?.bk) MintsWebViewActivity.toBaduVR(lat, lng, response.result?.bk)
) )
} }
}) })
} else { } else {
...@@ -183,7 +176,9 @@ class HomeViewModel(application: Application) : BaseViewModel(application) { ...@@ -183,7 +176,9 @@ class HomeViewModel(application: Application) : BaseViewModel(application) {
if (requestCode == 200 && resultCode == SearchMapActivity.REQUEST_CODE) { if (requestCode == 200 && resultCode == SearchMapActivity.REQUEST_CODE) {
data?.let { data?.let {
pt.value = GPS( pt.value = GPS(
it.getDoubleExtra("latitude", 0.0), it.getDoubleExtra("longitude", 0.0) it.getDoubleExtra("latitude", 0.0),
it.getDoubleExtra("longitude", 0.0),
it.getIntExtra("inner", 0)
) )
} }
} }
......
...@@ -34,6 +34,7 @@ class SearchAfterItem(viewModel: SearchMapViewModel,val name:String? ...@@ -34,6 +34,7 @@ class SearchAfterItem(viewModel: SearchMapViewModel,val name:String?
val intent = Intent() val intent = Intent()
intent.putExtra("latitude",pt?.lat) intent.putExtra("latitude",pt?.lat)
intent.putExtra("longitude",pt?.lng) intent.putExtra("longitude",pt?.lng)
intent.putExtra("inner",viewModel.index.value)
viewModel.finishData(SearchMapActivity.REQUEST_CODE,intent) viewModel.finishData(SearchMapActivity.REQUEST_CODE,intent)
}) })
} }
...@@ -66,7 +66,7 @@ public class ScrollLayout extends ViewGroup { ...@@ -66,7 +66,7 @@ public class ScrollLayout extends ViewGroup {
private void init(Context context) { private void init(Context context) {
touchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); touchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
slideSlop = AppUtils.dp2Px(context, 45); slideSlop = AppUtils.dp2Px(context, 45);
offsetB = AppUtils.dp2Px(context, 60); offsetB = AppUtils.dp2Px(context, 100);
animator = ValueAnimator.ofFloat(0f, 1f); animator = ValueAnimator.ofFloat(0f, 1f);
animator.setDuration(200); animator.setDuration(200);
animator.setInterpolator(new LinearInterpolator()); animator.setInterpolator(new LinearInterpolator());
...@@ -199,8 +199,7 @@ public class ScrollLayout extends ViewGroup { ...@@ -199,8 +199,7 @@ public class ScrollLayout extends ViewGroup {
//下滑offset就是负数,上滑就是正数 //下滑offset就是负数,上滑就是正数
int offset = (int) (lastY - eY); int offset = (int) (lastY - eY);
lastY = eY; lastY = eY;
if ((status == STATUS_EXTEND if (status == STATUS_EXTEND
|| status == STATUS_CLOSE)
&& super.dispatchTouchEvent(ev)) { && super.dispatchTouchEvent(ev)) {
return true; return true;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment