Commit eefdbecc authored by fengruiyu's avatar fengruiyu

首页的百度地图卡顿

首页底部搜索栏下面,要露出一部分
H5交互放大缩小的功能
parent 4d1b0124
...@@ -71,6 +71,14 @@ function doAppFun(funstr, params) { ...@@ -71,6 +71,14 @@ function doAppFun(funstr, params) {
} }
); );
} }
function centerChanged() {
try {
doAppFun("centerChanged", msg);
} catch (e) {
console.log("tips",msg)
//alert("app未弹框==>" + msg + e)
}
}
function tips(msg) { function tips(msg) {
try { try {
...@@ -118,6 +126,16 @@ connectWebViewJavascriptBridge(function (bridge) { ...@@ -118,6 +126,16 @@ connectWebViewJavascriptBridge(function (bridge) {
responseCallback("suc:initZsMap"); responseCallback("suc:initZsMap");
}); });
bridge.registerHandler("addZoom", function (data, responseCallback) {
addZoom();
responseCallback("suc:addZoom");
});
bridge.registerHandler("reduceZoom", function (data, responseCallback) {
reduceZoom();
responseCallback("suc:reduceZoom");
});
}) })
......
...@@ -9,7 +9,7 @@ function getZsKey() { ...@@ -9,7 +9,7 @@ function getZsKey() {
function getRequestUrl(a) { function getRequestUrl(a) {
return "http://maps."+getParam("base")+".com/" + getParam("u") + "" return "https://maps."+getParam("base")+"/" + getParam("u") + ""
} }
...@@ -18,10 +18,10 @@ function getVrUrls() { ...@@ -18,10 +18,10 @@ function getVrUrls() {
return [ return [
"http://lh3.ggpht."+getParam("base")+".com/" + getParam("u") + "/", "http://lh3.ggpht."+getParam("base")+"/" + getParam("u") + "/",
"http://lh4.ggpht."+getParam("base")+".com/" + getParam("u") + "/", "http://lh4.ggpht."+getParam("base")+"/" + getParam("u") + "/",
"http://lh5.ggpht."+getParam("base")+".com/" + getParam("u") + "/", "http://lh5.ggpht."+getParam("base")+"/" + getParam("u") + "/",
"http://lh6.ggpht."+getParam("base")+".com/" + getParam("u") + "/" "http://lh6.ggpht."+getParam("base")+"/" + getParam("u") + "/"
] ]
}; };
...@@ -31,10 +31,10 @@ function getVrUrls0(a) { ...@@ -31,10 +31,10 @@ function getVrUrls0(a) {
if ( getParam("ut") =='uz') if ( getParam("ut") =='uz')
return [ return [
"http://geo0.ggpht."+getParam("base")+".com/" + getParam("u") + "/cbk", "http://geo0.ggpht."+getParam("base")+"/" + getParam("u") + "/cbk",
"http://geo1.ggpht."+getParam("base")+".com/" + getParam("u") + "/cbk", "http://geo1.ggpht."+getParam("base")+"/" + getParam("u") + "/cbk",
"http://geo2.ggpht."+getParam("base")+".com/" + getParam("u") + "/cbk", "http://geo2.ggpht."+getParam("base")+"/" + getParam("u") + "/cbk",
"http://geo3.ggpht."+getParam("base")+".com/" + getParam("u") + "/cbk" "http://geo3.ggpht."+getParam("base")+"/" + getParam("u") + "/cbk"
] ]
...@@ -48,16 +48,16 @@ function getVrUrls0(a) { ...@@ -48,16 +48,16 @@ function getVrUrls0(a) {
function getMb1U() { function getMb1U() {
return [ return [
"http://khms0."+getParam("base")+".com/" + getParam("u") + "/kh?v=904\u0026hl=zh-CN\u0026", "http://khms0."+getParam("base")+"/" + getParam("u") + "/kh?v=904\u0026hl=zh-CN\u0026",
"http://khms1."+getParam("base")+".com/" + getParam("u") + "/kh?v=904\u0026hl=zh-CN\u0026" "http://khms1."+getParam("base")+"/" + getParam("u") + "/kh?v=904\u0026hl=zh-CN\u0026"
] ]
} }
function getMb2U() { function getMb2U() {
return [ return [
"http://khms0."+getParam("base")+".com/" + getParam("u") + "/kh?v=130\u0026hl=zh-CN\u0026", "http://khms0."+getParam("base")+"/" + getParam("u") + "/kh?v=130\u0026hl=zh-CN\u0026",
"http://khms1."+getParam("base")+".com/" + getParam("u") + "/kh?v=130\u0026hl=zh-CN\u0026" "http://khms1."+getParam("base")+"/" + getParam("u") + "/kh?v=130\u0026hl=zh-CN\u0026"
] ]
} }
......
function getZsKey() {
return getParam("gk")==null?"":getParam("gk");
}
function getRequestUrl(a) {
return "http://maps."+getParam("base")+".com/" + getParam("u") + ""
}
function getVrUrls() {
return [
"http://lh3.ggpht."+getParam("base")+".com/" + getParam("u") + "/",
"http://lh4.ggpht."+getParam("base")+".com/" + getParam("u") + "/",
"http://lh5.ggpht."+getParam("base")+".com/" + getParam("u") + "/",
"http://lh6.ggpht."+getParam("base")+".com/" + getParam("u") + "/"
]
};
function getVrUrls0(a) {
if ( getParam("ut") =='uz')
return [
"http://geo0.ggpht."+getParam("base")+".com/" + getParam("u") + "/cbk",
"http://geo1.ggpht."+getParam("base")+".com/" + getParam("u") + "/cbk",
"http://geo2.ggpht."+getParam("base")+".com/" + getParam("u") + "/cbk",
"http://geo3.ggpht."+getParam("base")+".com/" + getParam("u") + "/cbk"
]
var date = Date.parse(new Date()) / 1000
console.log("kkkk")
return ['https://streetscape.xinzhi.space/' + date + '/' + md5(date).toUpperCase()+"/cbk"]
}
function getMb1U() {
return [
"http://khms0."+getParam("base")+".com/" + getParam("u") + "/kh?v=904\u0026hl=zh-CN\u0026",
"http://khms1."+getParam("base")+".com/" + getParam("u") + "/kh?v=904\u0026hl=zh-CN\u0026"
]
}
function getMb2U() {
return [
"http://khms0."+getParam("base")+".com/" + getParam("u") + "/kh?v=130\u0026hl=zh-CN\u0026",
"http://khms1."+getParam("base")+".com/" + getParam("u") + "/kh?v=130\u0026hl=zh-CN\u0026"
]
}
///
function wordToHex(lValue) {
let WordToHexValue = "",
WordToHexValueTemp = "",
lByte,
lCount;
for (lCount = 0; lCount <= 3; lCount++) {
lByte = lValue >>> lCount * 8 & 255;
WordToHexValueTemp = "0" + lByte.toString(16);
WordToHexValue = WordToHexValue + WordToHexValueTemp.substr(WordToHexValueTemp.length - 2, 2);
}
return WordToHexValue;
};
function rotateLeft(lValue, iShiftBits) {
return lValue << iShiftBits | lValue >>> 32 - iShiftBits;
};
function addUnsigned(lX, lY) {
let lX4, lY4, lX8, lY8, lResult;
lX8 = lX & 0x80000000;
lY8 = lY & 0x80000000;
lX4 = lX & 0x40000000;
lY4 = lY & 0x40000000;
lResult = (lX & 0x3FFFFFFF) + (lY & 0x3FFFFFFF);
if (lX4 & lY4) return lResult ^ 0x80000000 ^ lX8 ^ lY8;
if (lX4 | lY4) {
if (lResult & 0x40000000) return lResult ^ 0xC0000000 ^ lX8 ^ lY8; else return lResult ^ 0x40000000 ^ lX8 ^ lY8;
} else {
return lResult ^ lX8 ^ lY8;
}
};
function F(x, y, z) {
return x & y | ~x & z;
};
function G(x, y, z) {
return x & z | y & ~z;
};
function H(x, y, z) {
return x ^ y ^ z;
};
function I(x, y, z) {
return y ^ (x | ~z);
};
function FF(a, b, c, d, x, s, ac) {
a = addUnsigned(a, addUnsigned(addUnsigned(F(b, c, d), x), ac));
return addUnsigned(rotateLeft(a, s), b);
};
function GG(a, b, c, d, x, s, ac) {
a = addUnsigned(a, addUnsigned(addUnsigned(G(b, c, d), x), ac));
return addUnsigned(rotateLeft(a, s), b);
};
function HH(a, b, c, d, x, s, ac) {
a = addUnsigned(a, addUnsigned(addUnsigned(H(b, c, d), x), ac));
return addUnsigned(rotateLeft(a, s), b);
};
function II(a, b, c, d, x, s, ac) {
a = addUnsigned(a, addUnsigned(addUnsigned(I(b, c, d), x), ac));
return addUnsigned(rotateLeft(a, s), b);
};
function convertToWordArray(string) {
let lWordCount;
let lMessageLength = string.length;
let lNumberOfWordsTempOne = lMessageLength + 8;
let lNumberOfWordsTempTwo = (lNumberOfWordsTempOne - lNumberOfWordsTempOne % 64) / 64;
let lNumberOfWords = (lNumberOfWordsTempTwo + 1) * 16;
let lWordArray = Array(lNumberOfWords - 1);
let lBytePosition = 0;
let lByteCount = 0;
while (lByteCount < lMessageLength) {
lWordCount = (lByteCount - lByteCount % 4) / 4;
lBytePosition = lByteCount % 4 * 8;
lWordArray[lWordCount] = lWordArray[lWordCount] | string.charCodeAt(lByteCount) << lBytePosition;
lByteCount++;
}
lWordCount = (lByteCount - lByteCount % 4) / 4;
lBytePosition = lByteCount % 4 * 8;
lWordArray[lWordCount] = lWordArray[lWordCount] | 0x80 << lBytePosition;
lWordArray[lNumberOfWords - 2] = lMessageLength << 3;
lWordArray[lNumberOfWords - 1] = lMessageLength >>> 29;
return lWordArray;
};
function md5(string) {
let str = string + 'EfAvGE#aR@bC@VvdC223$xC23sWXR$vf'
let x = Array();
let k, AA, BB, CC, DD, a, b, c, d;
let S11 = 7,
S12 = 12,
S13 = 17,
S14 = 22;
let S21 = 5,
S22 = 9,
S23 = 14,
S24 = 20;
let S31 = 4,
S32 = 11,
S33 = 16,
S34 = 23;
let S41 = 6,
S42 = 10,
S43 = 15,
S44 = 21;
str = uTF8Encode(str);
x = convertToWordArray(str);
a = 0x67452301;
b = 0xEFCDAB89;
c = 0x98BADCFE;
d = 0x10325476;
for (k = 0; k < x.length; k += 16) {
AA = a;
BB = b;
CC = c;
DD = d;
a = FF(a, b, c, d, x[k + 0], S11, 0xD76AA478);
d = FF(d, a, b, c, x[k + 1], S12, 0xE8C7B756);
c = FF(c, d, a, b, x[k + 2], S13, 0x242070DB);
b = FF(b, c, d, a, x[k + 3], S14, 0xC1BDCEEE);
a = FF(a, b, c, d, x[k + 4], S11, 0xF57C0FAF);
d = FF(d, a, b, c, x[k + 5], S12, 0x4787C62A);
c = FF(c, d, a, b, x[k + 6], S13, 0xA8304613);
b = FF(b, c, d, a, x[k + 7], S14, 0xFD469501);
a = FF(a, b, c, d, x[k + 8], S11, 0x698098D8);
d = FF(d, a, b, c, x[k + 9], S12, 0x8B44F7AF);
c = FF(c, d, a, b, x[k + 10], S13, 0xFFFF5BB1);
b = FF(b, c, d, a, x[k + 11], S14, 0x895CD7BE);
a = FF(a, b, c, d, x[k + 12], S11, 0x6B901122);
d = FF(d, a, b, c, x[k + 13], S12, 0xFD987193);
c = FF(c, d, a, b, x[k + 14], S13, 0xA679438E);
b = FF(b, c, d, a, x[k + 15], S14, 0x49B40821);
a = GG(a, b, c, d, x[k + 1], S21, 0xF61E2562);
d = GG(d, a, b, c, x[k + 6], S22, 0xC040B340);
c = GG(c, d, a, b, x[k + 11], S23, 0x265E5A51);
b = GG(b, c, d, a, x[k + 0], S24, 0xE9B6C7AA);
a = GG(a, b, c, d, x[k + 5], S21, 0xD62F105D);
d = GG(d, a, b, c, x[k + 10], S22, 0x2441453);
c = GG(c, d, a, b, x[k + 15], S23, 0xD8A1E681);
b = GG(b, c, d, a, x[k + 4], S24, 0xE7D3FBC8);
a = GG(a, b, c, d, x[k + 9], S21, 0x21E1CDE6);
d = GG(d, a, b, c, x[k + 14], S22, 0xC33707D6);
c = GG(c, d, a, b, x[k + 3], S23, 0xF4D50D87);
b = GG(b, c, d, a, x[k + 8], S24, 0x455A14ED);
a = GG(a, b, c, d, x[k + 13], S21, 0xA9E3E905);
d = GG(d, a, b, c, x[k + 2], S22, 0xFCEFA3F8);
c = GG(c, d, a, b, x[k + 7], S23, 0x676F02D9);
b = GG(b, c, d, a, x[k + 12], S24, 0x8D2A4C8A);
a = HH(a, b, c, d, x[k + 5], S31, 0xFFFA3942);
d = HH(d, a, b, c, x[k + 8], S32, 0x8771F681);
c = HH(c, d, a, b, x[k + 11], S33, 0x6D9D6122);
b = HH(b, c, d, a, x[k + 14], S34, 0xFDE5380C);
a = HH(a, b, c, d, x[k + 1], S31, 0xA4BEEA44);
d = HH(d, a, b, c, x[k + 4], S32, 0x4BDECFA9);
c = HH(c, d, a, b, x[k + 7], S33, 0xF6BB4B60);
b = HH(b, c, d, a, x[k + 10], S34, 0xBEBFBC70);
a = HH(a, b, c, d, x[k + 13], S31, 0x289B7EC6);
d = HH(d, a, b, c, x[k + 0], S32, 0xEAA127FA);
c = HH(c, d, a, b, x[k + 3], S33, 0xD4EF3085);
b = HH(b, c, d, a, x[k + 6], S34, 0x4881D05);
a = HH(a, b, c, d, x[k + 9], S31, 0xD9D4D039);
d = HH(d, a, b, c, x[k + 12], S32, 0xE6DB99E5);
c = HH(c, d, a, b, x[k + 15], S33, 0x1FA27CF8);
b = HH(b, c, d, a, x[k + 2], S34, 0xC4AC5665);
a = II(a, b, c, d, x[k + 0], S41, 0xF4292244);
d = II(d, a, b, c, x[k + 7], S42, 0x432AFF97);
c = II(c, d, a, b, x[k + 14], S43, 0xAB9423A7);
b = II(b, c, d, a, x[k + 5], S44, 0xFC93A039);
a = II(a, b, c, d, x[k + 12], S41, 0x655B59C3);
d = II(d, a, b, c, x[k + 3], S42, 0x8F0CCC92);
c = II(c, d, a, b, x[k + 10], S43, 0xFFEFF47D);
b = II(b, c, d, a, x[k + 1], S44, 0x85845DD1);
a = II(a, b, c, d, x[k + 8], S41, 0x6FA87E4F);
d = II(d, a, b, c, x[k + 15], S42, 0xFE2CE6E0);
c = II(c, d, a, b, x[k + 6], S43, 0xA3014314);
b = II(b, c, d, a, x[k + 13], S44, 0x4E0811A1);
a = II(a, b, c, d, x[k + 4], S41, 0xF7537E82);
d = II(d, a, b, c, x[k + 11], S42, 0xBD3AF235);
c = II(c, d, a, b, x[k + 2], S43, 0x2AD7D2BB);
b = II(b, c, d, a, x[k + 9], S44, 0xEB86D391);
a = addUnsigned(a, AA);
b = addUnsigned(b, BB);
c = addUnsigned(c, CC);
d = addUnsigned(d, DD);
}
let tempValue = wordToHex(a) + wordToHex(b) + wordToHex(c) + wordToHex(d);
return tempValue.toLowerCase();
}
function uTF8Encode(string) {
string = string.replace(/\x0d\x0a/g, "\x0a");
let output = "";
for (let n = 0; n < string.length; n++) {
let c = string.charCodeAt(n);
if (c < 128) {
output += String.fromCharCode(c);
} else if (c > 127 && c < 2048) {
output += String.fromCharCode(c >> 6 | 192);
output += String.fromCharCode(c & 63 | 128);
} else {
output += String.fromCharCode(c >> 12 | 224);
output += String.fromCharCode(c >> 6 & 63 | 128);
output += String.fromCharCode(c & 63 | 128);
}
}
return output;
};
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<title>普通地图&全景图</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script>
document.write('<script type="text/javascript"' +
' src="https://api.map.baidu.com/api?v=3.0&ak=' + getParam("bk") + '"><\/script>')
</script>
<style type="text/css">
body, html{width: 100%;height: 100%;overflow: hidden;margin:0;font-family:"微软雅黑";}
#panorama {height: 70%;overflow: hidden;}
#normal_map {height:30%;overflow: hidden;}
.anchorBL{
display: none !important;
}
a{
display: none !important;
}
#panorama span{
display: none !important;
}
.BMap_Marker{
position:fixed !important; /*绝对定位*/
left:50% !important;
top: 85% !important;
margin-left: -20px !important;
margin-top: -32px !important;
z-index: 99999999999 !important;
}
</style>
</head>
<body>
<div id="panorama"></div>
<div id="normal_map"></div>
<script type="text/javascript">
var c = 1;//getParam("c");//39.915表示纬度
var lat = getParam("lat");//39.915表示纬度
var lng = getParam("lng");//39.915表示纬度
var d = getParam("d");//39.915表示纬度
console.log("baiduinit",lat,lng,d)
//全景图展示
var panorama = new BMap.Panorama('panorama');
// panorama.setPosition(new BMap.Point(120.320032, 31.589666)); //根据经纬度坐标展示全景图
panorama.setPov({heading: -40, pitch: 6});
//panorama.setPanoramaPOIType(BMAP_PANORAMA_POI_CATERING); //餐饮
panorama.setPov({pitch: 6, heading: 138});
if (d != null && d != "") {
panorama.setId(d);//根据全景id展示全景图
} else {
panorama.setPosition(new BMap.Point(lng, lat));
}
panorama.addEventListener('position_changed', function(e){ //全景图位置改变后,普通地图中心点也随之改变
var pos = panorama.getPosition();
map.setCenter(new BMap.Point(pos.lng, pos.lat));
marker.setPosition(pos);
});
panorama.addEventListener('pov_changed', function(e){ //全景图方向改变后,普通地图中心点也随之改变
var pov = panorama.getPov();
// console.log('方向pov=',pov.heading);
// map.setCenter(new BMap.Point(pos.lng, pos.lat));
// marker.setPosition(pos);
marker.setRotation (pov.heading);
});
//普通地图展示
var mapOption = {
mapType: BMAP_HYBRID_MAP ,
maxZoom: 18,
drawMargin:0,
enableFulltimeSpotClick: true,
enableHighResolution:true
}
var map = new BMap.Map("normal_map", mapOption);
var testpoint = new BMap.Point(120.320032, 31.589666);
map.centerAndZoom(testpoint, 18);
// 创建小车图标
var myIcon = new BMap.Icon("./common/bm.jpg", new BMap.Size(40, 63),{
// anchor: new BMap.Size(0, 0)
// imageOffset:new BMap.Size(0, -15),
imageSize:new BMap.Size(40, 39)
// imageSize:new BMap.Size(40, 39)
})
var marker=new BMap.Marker(testpoint,{icon:myIcon});
//marker.enableDragging();
map.addOverlay(marker);
// marker.addEventListener('dragend',function(e){
// console.log("1")
// panorama.setPosition(e.point); //拖动marker后,全景图位置也随着改变
// panorama.setPov({heading: -40, pitch: 6});
// });
map.addEventListener('dragging',function(e){
// console.log(map.getCenter())
marker.setPosition(map.getCenter());
});
map.addEventListener('dragend',function(e){
console.log(map.getCenter())
marker.setPosition(map.getCenter());
panorama.setPosition(map.getCenter()); //拖动marker后,全景图位置也随着改变
panorama.setPov({heading: marker.getRotation(), pitch: 6});
});
</script>
</body>
</html>
\ No newline at end of file
...@@ -182,9 +182,8 @@ function loadGoogleMap(Yda) { ...@@ -182,9 +182,8 @@ function loadGoogleMap(Yda) {
})(); })();
function al() { function al() {
if (canclick) { if (canclick) {
canclick = false; canclick = false;
setTimeout(function () { setTimeout(function () {
...@@ -213,7 +212,8 @@ function al() { ...@@ -213,7 +212,8 @@ function al() {
}); });
} }
function tosh(center) { function tosh(center) {
console.log("查询国外或中国台湾街景") console.log("查询国外或中国台湾街景")
...@@ -227,7 +227,6 @@ function al() { ...@@ -227,7 +227,6 @@ function al() {
preference: 'nearest', //google.maps.StreetViewPreference.NEAREST, preference: 'nearest', //google.maps.StreetViewPreference.NEAREST,
}; };
ser.getPanorama(request, function (a) { ser.getPanorama(request, function (a) {
if (a == null || a.location == null) { if (a == null || a.location == null) {
tips("暂无街景") tips("暂无街景")
...@@ -251,7 +250,7 @@ function al() { ...@@ -251,7 +250,7 @@ function al() {
} }
//var arr =[120.31, 31.58] //var arr =[120.31, 31.58]
var initMap=function () { var initMap = function () {
console.log("initMap>>first") console.log("initMap>>first")
...@@ -263,7 +262,7 @@ var initMap=function () { ...@@ -263,7 +262,7 @@ var initMap=function () {
lng: 116.3972282409668 lng: 116.3972282409668
}, },
mapTypeId: "hybrid", mapTypeId: "hybrid",
zoomControl: true, zoomControl: false,
mapTypeControl: false, mapTypeControl: false,
scaleControl: false, scaleControl: false,
streetViewControl: false, streetViewControl: false,
...@@ -283,7 +282,29 @@ var initMap=function () { ...@@ -283,7 +282,29 @@ var initMap=function () {
*/ */
} }
function addZoom() {
var zoom = map.getZoom();
if(zoom==20){
tip("已放大至最大级别")
return;
}
zoom += 1;
map.setZoom(zoom);
}
function reduceZoom() {
var zoom = map.getZoom();
if(zoom==0){
tip("已缩放至最小级别")
return;
}
zoom -= 1;
map.setZoom(zoom);
}
window.onload = function () { window.onload = function () {
...@@ -297,18 +318,18 @@ function initZsMap(pointStr) { ...@@ -297,18 +318,18 @@ function initZsMap(pointStr) {
var point = JSON.parse(pointStr) var point = JSON.parse(pointStr)
if (mapInited == false) {//第一次初始化 if (mapInited == false) {//第一次初始化
mapInited=true; mapInited = true;
initMap=function () { initMap = function () {
console.log("initMap>>second") console.log("initMap>>second")
map = new google.maps.Map(document.getElementById("map"), { map = new google.maps.Map(document.getElementById("map"), {
zoom: 14, zoom: 14,
// RotateControlOptions :RIGHT_CENTER, // RotateControlOptions :RIGHT_CENTER,
center:point, center: point,
mapTypeId: "hybrid", mapTypeId: "hybrid",
zoomControl: true, zoomControl: false,
mapTypeControl: false, mapTypeControl: false,
scaleControl: false, scaleControl: false,
streetViewControl: false, streetViewControl: false,
...@@ -330,6 +351,9 @@ function initZsMap(pointStr) { ...@@ -330,6 +351,9 @@ function initZsMap(pointStr) {
window.google.maps.Load && window.google.maps.Load(ZSYDa); window.google.maps.Load && window.google.maps.Load(ZSYDa);
map.addListener("center_changed", () => {
centerChanged();
});
} else { } else {
......
...@@ -10,6 +10,7 @@ import com.baidu.location.BDLocation ...@@ -10,6 +10,7 @@ import com.baidu.location.BDLocation
import com.baidu.location.BDLocationListener import com.baidu.location.BDLocationListener
import com.baidu.location.LocationClient import com.baidu.location.LocationClient
import com.baidu.location.LocationClientOption import com.baidu.location.LocationClientOption
import com.baidu.mapapi.map.MapStatusUpdateFactory
import com.fry.base.base.BaseFragment import com.fry.base.base.BaseFragment
import com.github.lzyzsd.jsbridge.CallBackFunction import com.github.lzyzsd.jsbridge.CallBackFunction
import com.github.lzyzsd.jsbridge.DefaultHandler import com.github.lzyzsd.jsbridge.DefaultHandler
...@@ -24,6 +25,7 @@ import com.mints.street.main.home.HomeViewModel ...@@ -24,6 +25,7 @@ import com.mints.street.main.home.HomeViewModel
import com.mints.street.main.home.SearchMapActivity import com.mints.street.main.home.SearchMapActivity
import com.mints.street.utils.GPSConverterUtils import com.mints.street.utils.GPSConverterUtils
import com.mints.street.webview.MintsWebViewActivity import com.mints.street.webview.MintsWebViewActivity
import com.mints.street.widget.ScrollLayout
import me.goldze.mvvmhabit.base.AppManager import me.goldze.mvvmhabit.base.AppManager
import me.goldze.mvvmhabit.utils.CommonDialogUtils import me.goldze.mvvmhabit.utils.CommonDialogUtils
import me.goldze.mvvmhabit.utils.KLog import me.goldze.mvvmhabit.utils.KLog
...@@ -137,7 +139,18 @@ class GoogleMapFragment() : BaseFragment<ActivityGoogleMapBinding, HomeViewModel ...@@ -137,7 +139,18 @@ class GoogleMapFragment() : BaseFragment<ActivityGoogleMapBinding, HomeViewModel
//定位 //定位
initPosition() initPosition()
//使地图缩放级别增大一级
binding.imageIn.setOnClickListener {
binding.webview.callHandler("addZoom"
,null ) {
}
}
//使地图缩放级别减小一级
binding.imageOut.setOnClickListener {
binding.webview.callHandler("reduceZoom"
,null ) {
}
}
binding.imageLocationIcon.setOnClickListener { binding.imageLocationIcon.setOnClickListener {
initZsMap() initZsMap()
...@@ -217,6 +230,7 @@ class GoogleMapFragment() : BaseFragment<ActivityGoogleMapBinding, HomeViewModel ...@@ -217,6 +230,7 @@ class GoogleMapFragment() : BaseFragment<ActivityGoogleMapBinding, HomeViewModel
binding.webview.callHandler("initZsMap" binding.webview.callHandler("initZsMap"
,Gson().toJson(it) ) { ,Gson().toJson(it) ) {
} }
binding.scrollLayout.toggle(ScrollLayout.STATUS_CLOSE)
}) })
} }
override fun onDestroy() { override fun onDestroy() {
......
...@@ -10,10 +10,10 @@ import me.goldze.mvvmhabit.binding.command.BindingCommand ...@@ -10,10 +10,10 @@ import me.goldze.mvvmhabit.binding.command.BindingCommand
*/ */
class HomeButtonItemVM(viewModel: HomeViewModel,val name:String?,val image1:String, class HomeButtonItemVM(viewModel: HomeViewModel,val name:String?,val image1:String,
val image2:String,val image3:String, val image2:String,val image3:String,
var latitude:String?,var longitude:String?) : ItemViewModel<HomeViewModel?>(viewModel) { var latitude:String?,var longitude:String?,val isLook:Boolean?=false) : ItemViewModel<HomeViewModel?>(viewModel) {
val onItemClick = BindingCommand<Any?>(BindingAction { val onItemClick = BindingCommand<Any?>(BindingAction {
viewModel.authorized(name,latitude,longitude) viewModel.authorized(name,latitude,longitude,isLook?:false)
}) })
} }
\ No newline at end of file
package com.mints.street.main.home package com.mints.street.main.home
import android.content.Context.SENSOR_SERVICE import android.content.Context.SENSOR_SERVICE
import android.graphics.Color
import android.hardware.Sensor import android.hardware.Sensor
import android.hardware.SensorEvent import android.hardware.SensorEvent
import android.hardware.SensorEventListener import android.hardware.SensorEventListener
import android.hardware.SensorManager import android.hardware.SensorManager
import android.os.Bundle import android.os.Bundle
import android.os.Handler
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.TextView
import androidx.lifecycle.Observer import androidx.lifecycle.Observer
import com.baidu.location.BDLocation import com.baidu.location.BDLocation
import com.baidu.location.BDLocationListener import com.baidu.location.BDLocationListener
...@@ -17,19 +16,14 @@ import com.baidu.location.LocationClient ...@@ -17,19 +16,14 @@ import com.baidu.location.LocationClient
import com.baidu.location.LocationClientOption import com.baidu.location.LocationClientOption
import com.baidu.mapapi.map.* import com.baidu.mapapi.map.*
import com.baidu.mapapi.model.LatLng import com.baidu.mapapi.model.LatLng
import com.baidu.mapapi.search.core.RecommendStopInfo
import com.baidu.mapapi.search.recommendstop.RecommendStopSearch
import com.baidu.mapapi.search.recommendstop.RecommendStopSearchOption
import com.fry.base.base.BaseFragment import com.fry.base.base.BaseFragment
import com.google.gson.Gson import com.google.gson.Gson
import com.mints.street.BR import com.mints.street.BR
import com.mints.street.R import com.mints.street.R
import com.mints.street.bean.PositioningBean import com.mints.street.bean.PositioningBean
import com.mints.street.databinding.FragmentHomeBinding import com.mints.street.databinding.FragmentHomeBinding
import com.mints.street.main.my.OpenvipActivity
import com.mints.street.manager.UmengManager import com.mints.street.manager.UmengManager
import com.mints.street.utils.GPSConverterUtils import com.mints.street.utils.GPSConverterUtils
import com.mints.street.webview.MintsWebViewActivity
import com.mints.street.widget.ScrollLayout import com.mints.street.widget.ScrollLayout
import me.goldze.mvvmhabit.base.AppManager import me.goldze.mvvmhabit.base.AppManager
import me.goldze.mvvmhabit.utils.KLog import me.goldze.mvvmhabit.utils.KLog
...@@ -42,17 +36,12 @@ import me.goldze.mvvmhabit.utils.SPUtils ...@@ -42,17 +36,12 @@ import me.goldze.mvvmhabit.utils.SPUtils
*/ */
class HomeFragment : BaseFragment<FragmentHomeBinding, HomeViewModel>(), SensorEventListener { class HomeFragment : BaseFragment<FragmentHomeBinding, HomeViewModel>(), SensorEventListener {
private val userManager by lazy { com.mints.street.manager.UserManager.INSTANCE }
private var mBaiduMap: BaiduMap? = null private var mBaiduMap: BaiduMap? = null
private val mBitmapDescriptor = BitmapDescriptorFactory.fromResource(R.mipmap.positioning_icon)
private var mRecommendStopSearch: RecommendStopSearch? = null
// 定位相关 // 定位相关
private var mLocClient: LocationClient? = null private var mLocClient: LocationClient? = null
private var isScrollLayoutClose:Boolean= false
// 定位图层显示方式 // 定位图层显示方式
private var mCurrentMode: MyLocationConfiguration.LocationMode? = null private var mCurrentMode: MyLocationConfiguration.LocationMode? = null
private var mSensorManager: SensorManager? = null private var mSensorManager: SensorManager? = null
...@@ -105,11 +94,12 @@ class HomeFragment : BaseFragment<FragmentHomeBinding, HomeViewModel>(), SensorE ...@@ -105,11 +94,12 @@ class HomeFragment : BaseFragment<FragmentHomeBinding, HomeViewModel>(), SensorE
override fun initData() { override fun initData() {
super.initData() super.initData()
Handler().postDelayed({ isScrollLayoutClose = true },2000)
RxUtils.onMultiClick(binding.stbBgSearch) { RxUtils.onMultiClick(binding.stbBgSearch) {
SearchMapActivity.startSearchMapActivity(this) SearchMapActivity.startSearchMapActivity(this)
} }
RxUtils.onMultiClick(binding.ivClick){ RxUtils.onMultiClick(binding.ivClick){
viewModel.authorized("",currentLat.toString(), currentLon.toString()) viewModel.authorized("",currentLat.toString(), currentLon.toString(),false)
} }
viewModel.getMapBean() viewModel.getMapBean()
} }
...@@ -121,7 +111,7 @@ class HomeFragment : BaseFragment<FragmentHomeBinding, HomeViewModel>(), SensorE ...@@ -121,7 +111,7 @@ class HomeFragment : BaseFragment<FragmentHomeBinding, HomeViewModel>(), SensorE
val gps = GPSConverterUtils.gcj02_To_Bd09(it.lat,it.lng) val gps = GPSConverterUtils.gcj02_To_Bd09(it.lat,it.lng)
val center = LatLng(gps.lat, gps.lng) val center = LatLng(gps.lat, gps.lng)
setNewMapStatus(center) setNewMapStatus(center)
binding.scrollLayout.toggle(ScrollLayout.STATUS_DEFAULT) binding.scrollLayout.toggle(ScrollLayout.STATUS_CLOSE)
}) })
} }
...@@ -144,35 +134,29 @@ class HomeFragment : BaseFragment<FragmentHomeBinding, HomeViewModel>(), SensorE ...@@ -144,35 +134,29 @@ class HomeFragment : BaseFragment<FragmentHomeBinding, HomeViewModel>(), SensorE
mBaiduMap?.setMapStatus(mapStatusUpdate) mBaiduMap?.setMapStatus(mapStatusUpdate)
mBaiduMap?.setOnMapStatusChangeListener(object : BaiduMap.OnMapStatusChangeListener { mBaiduMap?.setOnMapStatusChangeListener(object : BaiduMap.OnMapStatusChangeListener {
override fun onMapStatusChangeStart(status: MapStatus?) { override fun onMapStatusChangeStart(status: MapStatus?) {
//KLog.a("百度map", "移动开始") KLog.a("百度map", "移动开始")
} }
override fun onMapStatusChangeStart(status: MapStatus?, reason: Int) { override fun onMapStatusChangeStart(status: MapStatus?, reason: Int) {
// KLog.a("百度map", "移动开始,两个参数") KLog.a("百度map", "移动开始,两个参数")
} }
override fun onMapStatusChange(status: MapStatus?) { override fun onMapStatusChange(status: MapStatus?) {
//KLog.a("百度map", "移动改变") KLog.a("百度map", "移动改变")
if (!binding.scrollLayout.isClose&& isScrollLayoutClose){
binding.scrollLayout.post {
binding.scrollLayout.toggle(ScrollLayout.STATUS_CLOSE)
}
}
} }
override fun onMapStatusChangeFinish(status: MapStatus?) { override fun onMapStatusChangeFinish(status: MapStatus?) {
// KLog.a("百度map", "移动结束") KLog.a("百度map", "移动结束")
currentLat = status?.target?.latitude?:0.0 currentLat = status?.target?.latitude?:0.0
currentLon = status?.target?.longitude?:0.0 currentLon = status?.target?.longitude?:0.0
mRecommendStopSearch?.requestRecommendStop(
RecommendStopSearchOption().location(
LatLng(currentLat,currentLat)
)
)
} }
}) })
mBaiduMap?.setOnMapLoadedCallback {
mRecommendStopSearch?.requestRecommendStop(RecommendStopSearchOption().location( LatLng(currentLat,currentLat)))
}
//使地图缩放级别增大一级 //使地图缩放级别增大一级
binding.imageIn.setOnClickListener { binding.imageIn.setOnClickListener {
mBaiduMap?.setMapStatus(MapStatusUpdateFactory.zoomIn()) mBaiduMap?.setMapStatus(MapStatusUpdateFactory.zoomIn())
...@@ -185,12 +169,6 @@ class HomeFragment : BaseFragment<FragmentHomeBinding, HomeViewModel>(), SensorE ...@@ -185,12 +169,6 @@ class HomeFragment : BaseFragment<FragmentHomeBinding, HomeViewModel>(), SensorE
binding.imageMapHistory.setOnClickListener { binding.imageMapHistory.setOnClickListener {
startActivity(HistoricalimageActivity::class.java) startActivity(HistoricalimageActivity::class.java)
} }
mRecommendStopSearch = RecommendStopSearch.newInstance()
mRecommendStopSearch?.setOnGetRecommendStopResultListener { result ->
if (result != null) {
addMarkerToMap(result.recommendStopInfoList)
}
}
//重新回到定位点 //重新回到定位点
RxUtils.onMultiClick(binding.imageLocationIcon) { RxUtils.onMultiClick(binding.imageLocationIcon) {
// 默认 天安门 // 默认 天安门
...@@ -260,41 +238,10 @@ class HomeFragment : BaseFragment<FragmentHomeBinding, HomeViewModel>(), SensorE ...@@ -260,41 +238,10 @@ class HomeFragment : BaseFragment<FragmentHomeBinding, HomeViewModel>(), SensorE
mLocClient?.stop() mLocClient?.stop()
// 关闭定位图层 // 关闭定位图层
mBaiduMap?.isMyLocationEnabled = false mBaiduMap?.isMyLocationEnabled = false
mRecommendStopSearch?.destroy()
binding.bmapView.onDestroy() binding.bmapView.onDestroy()
} }
/**
* 推荐上车点添加到地图上
* @param stops 推荐上车点列表
*/
private fun addMarkerToMap(stops: List<RecommendStopInfo?>?) {
stops?.apply {
mBaiduMap?.clear()
for (stop in this) {
stop?.apply {
KLog.e("addMarkerToMap", this.location.latitude)
KLog.e("addMarkerToMap", this.location.latitude)
val textView = TextView(context)
textView.text = stop.name
textView.setBackgroundColor(Color.WHITE)
val infoWindow = InfoWindow(
textView,
stop.location, -47
)
val markerOptions = MarkerOptions()
markerOptions.icon(mBitmapDescriptor).position(stop.location).scaleX(0.5f)
.scaleY(0.5f)
.infoWindow(infoWindow)
mBaiduMap!!.addOverlay(markerOptions)
}
}
}
}
/** /**
* 定位SDK监听函数 * 定位SDK监听函数
......
...@@ -53,11 +53,14 @@ class HomeViewModel(application: Application):BaseViewModel(application) { ...@@ -53,11 +53,14 @@ class HomeViewModel(application: Application):BaseViewModel(application) {
}) })
} }
fun authorized(name:String?=null,lat:String?,lng:String?) { fun authorized(name:String?=null,lat:String?,lng:String?,isLook:Boolean) {
if(!UserManager.INSTANCE.userIsLogin() && !UserManager.INSTANCE.getVipFlag()){ if (!isLook){
if((!UserManager.INSTANCE.userIsLogin() && !UserManager.INSTANCE.getVipFlag())){
startActivity(OpenvipActivity::class.java) startActivity(OpenvipActivity::class.java)
return return
} }
}
ApiModel.authorized().safeSubscribe(object ApiModel.authorized().safeSubscribe(object
: HttpSubscribeImpl<BaseResponse<AuthorizedBean>>( : HttpSubscribeImpl<BaseResponse<AuthorizedBean>>(
this@HomeViewModel,false this@HomeViewModel,false
...@@ -98,7 +101,7 @@ class HomeViewModel(application: Application):BaseViewModel(application) { ...@@ -98,7 +101,7 @@ class HomeViewModel(application: Application):BaseViewModel(application) {
} }
addressList.add(HomeButtonItemVM(this, item.name addressList.add(HomeButtonItemVM(this, item.name
, item.images!![0],item.images!![1],item.images!![2] , item.images!![0],item.images!![1],item.images!![2]
,latitude = item.latitude.toString(),longitude = item.longitude.toString() ,latitude = item.latitude.toString(),longitude = item.longitude.toString(),isLook = true
)) ))
} }
......
...@@ -38,7 +38,7 @@ class MintsWebViewActivity : BaseActivity<ActivityMintsWebViewBinding, MintsWebV ...@@ -38,7 +38,7 @@ class MintsWebViewActivity : BaseActivity<ActivityMintsWebViewBinding, MintsWebV
}&gk=${gk}&base=${base}&lat=${lat}&lng=${lng}&ut=${ut}" }&gk=${gk}&base=${base}&lat=${lat}&lng=${lng}&ut=${ut}"
} }
fun toBaduVR(d:String?,bk:String?):String{ fun toBaduVR(d:String?,bk:String?):String{
KLog.i("MintsWebViewActivity","file:///android_asset/web/m.html?d=${d}&bk=${bk}") KLog.i("MintsWebViewActivity","file:///android_asset/web/mr.html?d=${d}&bk=${bk}")
return "file:///android_asset/web/m.html?d=${d}&bk=${bk}" return "file:///android_asset/web/m.html?d=${d}&bk=${bk}"
} }
fun toBaduVR(lat:String?,lng:String?,bk:String?):String{ fun toBaduVR(lat:String?,lng:String?,bk:String?):String{
......
...@@ -125,7 +125,7 @@ public class ScrollLayout extends ViewGroup { ...@@ -125,7 +125,7 @@ public class ScrollLayout extends ViewGroup {
width = MeasureSpec.getSize(widthMeasureSpec); width = MeasureSpec.getSize(widthMeasureSpec);
height = MeasureSpec.getSize(heightMeasureSpec); height = MeasureSpec.getSize(heightMeasureSpec);
//界面下边显示出来的子View的高度 //界面下边显示出来的子View的高度
child_default_height = AppUtils.dp2Px(getContext(), 110); child_default_height = AppUtils.dp2Px(getContext(), 210);
offsetY = height - child_default_height; offsetY = height - child_default_height;
offsetExtend = offsetY - offsetB; offsetExtend = offsetY - offsetB;
offsetClose = offsetY + offsetB - height;//负数 向下移动到剩下40dp的高度 offsetClose = offsetY + offsetB - height;//负数 向下移动到剩下40dp的高度
...@@ -325,6 +325,9 @@ public class ScrollLayout extends ViewGroup { ...@@ -325,6 +325,9 @@ public class ScrollLayout extends ViewGroup {
animator.end(); animator.end();
} }
} }
public boolean isClose(){
return finalY == offsetClose;
}
/** /**
* 设置RecyclerView是否可滑动 * 设置RecyclerView是否可滑动
......
...@@ -21,17 +21,63 @@ ...@@ -21,17 +21,63 @@
/> />
<ImageView
android:visibility="gone"
android:id="@+id/image_map_history"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_marginTop="15dp"
android:src="@mipmap/map_history_icon"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/image_map_change" />
<ImageView <ImageView
android:id="@+id/image_location_icon" android:id="@+id/image_location_icon"
android:layout_width="42dp" android:layout_width="35dp"
android:layout_height="42dp" android:layout_height="35dp"
android:layout_marginTop="125dp" android:layout_marginBottom="120dp"
android:layout_marginEnd="6dp" android:layout_marginTop="15dp"
android:src="@mipmap/location_icon" android:src="@mipmap/location_icon"
app:layout_constraintBottom_toBottomOf="@+id/webview" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="@id/webview" app:layout_constraintEnd_toEndOf="parent" />
<LinearLayout
android:id="@+id/map_a_d"
android:layout_width="31dp"
android:layout_height="63dp"
android:layout_marginBottom="10dp"
android:layout_marginEnd="2dp"
android:background="@drawable/shape_gold_card"
android:orientation="vertical"
app:layout_constraintBottom_toTopOf="@id/image_location_icon"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
/>
>
<ImageView
android:id="@+id/image_in"
android:layout_width="31dp"
android:layout_height="31dp"
android:padding="10dp"
android:src="@mipmap/scale_add_icon" />
<ImageView
android:id="@+id/image_out"
android:layout_width="31dp"
android:layout_height="31dp"
android:padding="10dp"
android:src="@mipmap/scale_shrink_icon" />
<View
android:layout_width="wrap_content"
android:layout_height="0.5dp"
android:layout_marginEnd="12dp"
android:layout_marginStart="12dp"
android:background="@color/color_333" />
</LinearLayout>
<com.mints.street.widget.ScrollLayout <com.mints.street.widget.ScrollLayout
android:id="@+id/scroll_layout" android:id="@+id/scroll_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<com.baidu.mapapi.map.MapView <com.baidu.mapapi.map.TextureMapView
android:id="@+id/bmapView" android:id="@+id/bmapView"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="0dp" android:layout_height="0dp"
...@@ -117,7 +117,7 @@ ...@@ -117,7 +117,7 @@
android:id="@+id/image_under" android:id="@+id/image_under"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="8dp" android:padding="5dp"
android:src="@mipmap/icon_content_back" android:src="@mipmap/icon_content_back"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
......
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