https://www.cnblogs.com/mrer/p/7144705.html

 

地图位置编辑   —-https://lbs.qq.com/javascript_v2/case-run.html#sample-event-click

<!DOCTYPE html>
<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<meta name=”viewport” content=”width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no”/>
<title>点击地图事件</title>
<style type=”text/css”>
*{
margin:0px;
padding:0px;
}
body, button, input, select, textarea {
font: 12px/16px Verdana, Helvetica, Arial, sans-serif;
}
p{
width:603px;
padding-top:3px;
overflow:hidden;
}
#container {
min-width:603px;
min-height:767px;
}
</style>
<script charset=”utf-8″ src=”https://map.qq.com/api/js?v=2.exp&key=OB4BZ-D4W3U-B7VVO-4PJWW-6TKDJ-WPB77″></script>
<script>
var init = function() {
var center = new qq.maps.LatLng(39.916527,116.397128);
var map = new qq.maps.Map(document.getElementById(“container”),{
center: new qq.maps.LatLng(39.916527,116.397128),
zoom: 13
});
var marker = new qq.maps.Marker({
position: center,
map: map
});
//添加监听事件
qq.maps.event.addListener(map, \’click\’, function(event) {    //  —-监听拖拽事件dragend
console.log()
marker.setPosition(event.latLng)
changecenter(event.latLng)
});

function changecenter(data){
map.setCenter(data)
}
}
</script>
</head>
<body onload=”init()”>
<div id=”container”></div>
<p>给地图绑定了点击事件,当点击地图时,会弹出相应信息。</p>
</body>
</html>

版权声明:本文为Quxiya原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/Quxiya/p/10723749.html