Commit 68aac287 authored by fengruiyu's avatar fengruiyu

修改JS

配合JS添加 搜索地址返回到地图上标记功能已完成
parent 5cdb56e9
......@@ -40,9 +40,11 @@ var vm = new Vue({
markes: [],
pxValue: 50,
gdcenter: null,
vipLevel: 11,
notVipLevels: [1, 11, 14]
vipLevel: 14,
notVipLevels: [1, 11, 14],
nowP: null,
nowS: null,
iconType: 0,
},
created: function () {
// console.log('llll')
......@@ -113,7 +115,7 @@ var vm = new Vue({
// animation: google.maps.Animation.DROP,
optimized: true,
// collisionBehavior: 'OPTIONAL_AND_HIDES_LOWER_PRIORITY',
// collisionBehavior: 'OPTIONAL_AND_HIDES_LOWER_PRIORITY',
map: G_MAP,
label: {
text: msg.name,
......@@ -127,10 +129,10 @@ var vm = new Vue({
title: msg.bvid,
})
marker.addListener("click", (ss) => {
if (this.isVip == false) {
this.needPay('p');
return;
}
// if (this.isVip == false) {
// this.needPay('p');
// return;
// }
params = vm.getSeLabel(marker.getTitle());
if (params != null) {
// console.log(params);
......@@ -161,11 +163,13 @@ var vm = new Vue({
th.showScenics = inMsg.showScenics == 1;
th.scenics = inMsg.scenics;
th.isVip = inMsg.vip == 1;
th.initZsMap(inMsg, true);
th.iconType = 0;
th.initZsMap(inMsg);
},
initZsMap: function (inMsg, init) {
initZsMap: function (inMsg) {
var th = this;
th.isVip = inMsg.vip == 1;
th.iconType = inMsg.iconType == null ? 0 : inMsg.iconType;
if (inMsg.lat == 0 || inMsg.lng == 0 ||
inMsg.lat == '0' || inMsg.lng == '0') {
......@@ -179,18 +183,17 @@ var vm = new Vue({
if (inMsg.inner == null) {
toGPoint(point, function (r) {
console.log("定位 》》》toGooglePoint", r)
th.G_initMap(r, th.getLevel(), init);
th.G_initMap(r, th.getLevel());
})
} else {
if (inMsg.inner == 0 || inMsg == '0') {
toGPoint(point, function (r) {
console.log("国内 》》》toGooglePoint", r)
th.G_initMap(r, th.getLevel(), init);
th.G_initMap(r, th.getLevel());
})
} else {
console.log("国外 》》》toGooglePoint", point)
th.G_initMap(point, th.getLevel(), init);
th.G_initMap(point, th.getLevel());
}
}
......@@ -240,16 +243,16 @@ var vm = new Vue({
return;
}
},
needPay:function(d){
needPay: function (d) {
console.log("<<请开启会员")
if(d!=undefined&&d!=null&&d=='p'){
if (d != undefined && d != null && d == 'p') {
needPay();
return;
}
needPayPopup();
},
G_initMap: function (point, zoomLevel, init) {
G_initMap: function (point, zoomLevel) {
if (zoomLevel == undefined || zoomLevel == null)
zoomLevel = 15;
var th = this;
......@@ -307,27 +310,10 @@ var vm = new Vue({
}, false);
if (init) {//初始化
new google.maps.Marker({
position: point,
map: G_MAP,
icon: "./common/n.png",//msg.img,
// animation: google.maps.Animation.DROP,
optimized: true,
map: G_MAP,
// label: {
// text: "i am here",
// className: "zsmaker",
// // fontFamily: "Material Icons",
// color: "#ffffff",
// fontSize: "13px",
// fontWeight: '500'
// },
});
if (vm.showScenics)
vm.doShowScenics();
vm.setNowO(point);
}
if (vm.showScenics)
vm.doShowScenics();
}
......@@ -335,8 +321,36 @@ var vm = new Vue({
} else {
G_MAP.panTo(point) //第二次初始化
G_MAP.setZoom(zoomLevel)
vm.setNowO(point);
}
},
setNowO: function (point) {
if (this.iconType == 0) {
if (this.nowP == null) {
this.nowP = new google.maps.Marker({
position: point,
map: G_MAP,
icon: "./common/n2.png",//msg.img,
optimized: true,
map: G_MAP,
});
} else {
this.nowP.setPosition(point)
}
} else {
if (this.nowS == null) {
this.nowS = new google.maps.Marker({
position: point,
map: G_MAP,
icon: "./common/jd.png",//msg.img,
optimized: true,
map: G_MAP,
});
} else {
this.nowS.setPosition(point)
}
}
}
}
})
......
......@@ -129,8 +129,5 @@
<script type="text/javascript" charset="UTF-8" src="./zsmap_files/onion.js"></script>
<script type="text/javascript" charset="UTF-8" src="./zsmap_files/controls.js"></script>
<script src="./zsmap_files/js" async=""></script>
<script src="./common/vconsole.min.js"></script>
<script>
var vConsole = new VConsole();
</script>
</html>
......@@ -8,6 +8,7 @@ class InitMapBean {
var lng: Double = 0.0
var vip: Int? = 0//0 非vip 1 vip
var inner: Int? = 0// 0国内 ,1国外
var iconType: Int? = 0// 定位icon还是搜索之后的icon 0国内 ,1国外
var mapType:String?=null//当前地图类型
var showVrButton: Int? = 0 //是否展示街景按钮 1 展示,0 不展示
var showScenics: Int? = 0 //是否展示景点推荐 1 展示 ,0 不展示
......
......@@ -127,7 +127,7 @@ class GoogleMapFragment() : BaseFragment<ActivityGoogleMapBinding, HomeViewModel
//点击调转页面
viewModel.authorized(bvid, name)
//更新当前坐标(控制js页面做回调)
loadPosition(lat?.toDouble(), lng?.toDouble())
loadPosition(lat?.toDouble(), lng?.toDouble(),iconType = 1)
}
}
}).init().show()
......@@ -243,7 +243,7 @@ class GoogleMapFragment() : BaseFragment<ActivityGoogleMapBinding, HomeViewModel
* 调用JS
* 定位
*/
private fun loadPosition(lat: Double? = null, lng: Double? = null, inner: Int = 0) {
private fun loadPosition(lat: Double? = null, lng: Double? = null, inner: Int = 0,iconType:Int=0) {
val initMapBean = InitMapBean()
initMapBean.lat = lat ?: gps.lat
initMapBean.lng = lng ?: gps.lng
......@@ -256,6 +256,7 @@ class GoogleMapFragment() : BaseFragment<ActivityGoogleMapBinding, HomeViewModel
}
initMapBean.inner = inner
initMapBean.iconType = iconType
binding.webview.callHandler(
"initZsMap", Gson().toJson(initMapBean)
) {
......@@ -433,7 +434,7 @@ class GoogleMapFragment() : BaseFragment<ActivityGoogleMapBinding, HomeViewModel
})
//搜索页面回调参数
viewModel.pt.observe(this, Observer {
loadPosition(it.lat, it.lng, it.inner)
loadPosition(it.lat, it.lng, it.inner,1)
binding.scrollLayout.toggle(ScrollLayout.STATUS_CLOSE)
})
//获取地图展示样式
......
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