大家好,我在使用标记管理器将单个标记添加到谷歌地图 v3 时遇到问题。我知道管理器更适合添加数组,但我想了解如何在学习过程中添加单个标记。谁能指出我正确的方向?这是我目前正在使用的添加单个标记的代码:
<DOCTYPE! html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0px; padding: 0px }
#map_canvas { height: 100% }
</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(29.448903234142804, -98.51985454559326);
var myOptions = {
zoom: 10,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);
mgr = new MarkerManager(map);
var myLatlng = new google.maps.LatLng(29.448903234142804, -98.51985454559326);
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
title:"Hello World!"});
mgr.addMarker(marker,9,12);
mgr.refresh();}
</script>
</head>
<body onload="initialize()">
<div id="map_canvas" style="width:100%; height:100%"></div>
</body>
</html>