Commit 6858f40f authored by fengruiyu's avatar fengruiyu

修改 首页的推荐的功能

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