去掉自动定位到当前位置

修改appid和appsecret
l
Tuzki 2 years ago
parent a45596c1fc
commit 3f86129e27
  1. 2
      src/main/java/com/cjy/back/wx/WXController.java
  2. 31
      src/main/webapp/html/back/ybsjMap/ybsjMap.html

@ -24,7 +24,7 @@ public class WXController {
@PostMapping("/getUserInformation")
public ServerResponse getUserInformation(@RequestBody Map<String, Object> map) {
String code = StringUtils.isBlank(map.get("code") + "") ? "" : map.get("code") + "";
String url = "https://api.weixin.qq.com/sns/jscode2session?appid=wx111bbea67d1b06d5&secret=5d5a1ac827c9eab437a90927ebb8a47d&js_code=" + code + "&grant_type=authorization_code";
String url = "https://api.weixin.qq.com/sns/jscode2session?appid=wxe705d9b6caa89668&secret=7de82bf3dac8602180c1e57e023a741b&js_code=" + code + "&grant_type=authorization_code";
String result = HttpUtil.doGet(url);
return ServerResponse.createBySuccessMessage(result);
}

@ -193,14 +193,35 @@
'fillOpacity': 0.25
},
}
// map.plugin('AMap.Geolocation', function () {
// var geolocation = new AMap.Geolocation(options);
//
// map.addControl(geolocation);
//
// // geolocation.getCurrentPosition()
// map.event.addListener(geolocation, 'complete', onComplete);//返回定位信息
// map.event.addListener(geolocation, 'error', onError); //返回定位出错信息
// });
map.plugin('AMap.Geolocation', function () {
var geolocation = new AMap.Geolocation(options);
geolocation = new AMap.Geolocation({
enableHighAccuracy: true,//是否使用高精度定位,默认:true
timeout: 5000, //超过10秒后停止定位,默认:无穷大
zoomToAccuracy:false, //定位成功后调整地图视野范围使定位位置及精度范围视野内可见,默认:false
panToLocation:false,
buttonDom:'<img src="img/self-location.png" height="50" width="50"/>'
});
map.addControl(geolocation);
function onComplete(obj){
console.log(obj.message);
}
geolocation.getCurrentPosition()
map.event.addListener(geolocation, 'complete', onComplete);//返回定位信息
map.event.addListener(geolocation, 'error', onError); //返回定位出错信息
function onError(obj){
var position = new AMap.LngLat(clng, clat); // 标准写法
map.setCenter(position);
}
map.addControl(geolocation);
AMap.event.addListener(geolocation, 'complete', onComplete);//返回定位信息
AMap.event.addListener(geolocation, 'error', onError); //返回定位出错信息
});
foundMarker(data);
map.setZoom(start_maplevel)

Loading…
Cancel
Save