谷歌点击移动标记点击
我想做的是,
在我的地图上,当我点击地图上的某个地方时,它会在点上显示一个标记,然后我点击地图上的不同点,然后它会显示另一个标记。但我希望它将第一个标记移动到第二个点。
(我把“放在html标签后面,把代码放在这里。)
这是我的代码:
<html>
<style type="text/css">
#map_canvas {
height: 760px;
width: 1100px;
position: static;
top: 100px;
left: 200px;
}
</style>
<script type="text/javascript"
src="http://maps.google.com/maps/api/js?sensor=false">
</script>
<script type="text/javascript">
function initialize() {
var latlng = new google.maps.LatLng(42.55308, 9.140625);
var myOptions = {
zoom: 2,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP,
streetViewControl: false,
mapTypeControl: false,
};
var map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);
google.maps.event.addListener(map, 'click', function(event) {
placeMarker(event.latLng);
});
function placeMarker(location) {
var marker = new google.maps.Marker({
position: location,
map: map
animation: google.maps.Animation.DROP,
});
map.setCenter(location);
}
}
</script>
</head>
<body onload="initialize()">
<div id="map_canvas" style="1500px; 1000px"></div>
</body>
</html>
没有找到相关结果
已邀请:
3 个回复
室邢
时,它都会创建一个新标记。 您需要在地标标记功能之外创建一次标记,然后在地标标记内部使用
。
扇献隙
眠缝