【发布时间】:2013-12-10 16:42:57
【问题描述】:
我想在谷歌地图上通过鼠标移动事件移动标记。
以下是我在谷歌地图上添加标记的代码。
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<title>Simple markers</title>
<style>
html, body, #map-canvas {
height: 100%;
margin: 0px;
padding: 0px
}
</style>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
<script>
function initialize() {
var myLatlng = new google.maps.LatLng(-25.363882,131.044922);
var mapOptions = {
zoom: 4,
center: myLatlng
}
var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
title: 'Hello World!'
});
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="map-canvas"></div>
</body>
这是一个取自https://developers.google.com/maps/documentation/javascript/examples/marker-simple的简单标记示例
在鼠标移动时,我想用鼠标移动标记。但我不知道该怎么做
【问题讨论】:
-
您确定没有使标记可拖动吗? var marker = new google.maps.Marker({ position: myLatlng, map: map, title: 'Hello World!', draggalbe: true });
标签: javascript google-maps google-maps-api-3