//解析地址
analysis(position.lat, position.lng);
//绑定地图点击事件
qq.maps.event.addListener(map, "click", function (e) {
$('#poi_lat').html(e.latLng.getLat().toFixed(6));
$('#poi_lng').html(e.latLng.getLng().toFixed(6));
//先移除标记,再添加标记
marker.setMap(null);
marker = new qq.maps.Marker({
position: new qq.maps.LatLng(e.latLng.getLat(), e.latLng.getLng()),
map: map
});
analysis(e.latLng.getLat(), e.latLng.getLng());
});
//解析地址
function analysis(lat, lng) {
var url3 = encodeURI("https://apis.map.qq.com/ws/geocoder/v1/?location=" + lat + "," + lng + "&key=" + appkey + "&output=jsonp&&callback=?");
$.getJSON(url3, function (result) {
if (result.result != undefined) {
$('#poi_address').html(result.result.address);
} else {
$('#poi_address').html('');
}
})
}
Done!