我正在使用Google Maps Api v3显示 map 。
这是 JQuery:
<script type="text/javascript">
var myOptions = {
zoom: 8,
center: new google.maps.LatLng($("#lat").val(), $("#long").val()),
mapTypeId: google.maps.MapTypeId.HYBRID
};
var map = new google.maps.Map(document.getElementById("map"), myOptions);
但是 map 没有突出显示这一点。它只是显示 map 上的区域...我希望它看起来像这样:
最佳答案
用标记看一下这个例子的源代码: http://code.google.com/apis/maps/documentation/javascript/examples/infowindow-simple.html
使用您的代码的示例:
<script type="text/javascript" src="//maps.googleapis.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
function initialize() {
var myLatlng = new google.maps.LatLng($("#lat").val(), $("#long").val());
//var myLatlng = new google.maps.LatLng(-25.363882,131.044922);
var myOptions = {
zoom: 8,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.HYBRID
};
var map = new google.maps.Map(document.getElementById("map"), myOptions);
var contentString = '<div id="content">Info window html</div>';
var infowindow = new google.maps.InfoWindow({
content: contentString
});
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
title: 'Marker Title'
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map, marker);
});
}
</script>
</head>
<body onload="initialize()">
<div id="map" style="width: 400px; height: 300px;"></div>
</body>
关于jquery - 如何让谷歌地图 API v3 显示点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9664470/