上的標誌我建立這個腳本初始化一個地圖的特定點:顯示谷歌地圖地圖
注:(x, y)
的經緯度座標。
<script type="text/javascript">
var businessMap;
function showBusinessMap(x, y) {
var xops =
{
zoom: 15,
center: new google.maps.LatLng(x, y)
}
var chosenPoint = new google.maps.Marker({
position: new google.maps.LatLng(x, y),
});
businessMap = new google.maps.Map(document.getElementById("businessMap"), xops);
chosenPoint.setMap(businessMap);
chosenPoint.setVisible(true);
}
</script>
它工作的很好,但沒有標記顯示在地圖上。
我也有這個jQuery的功能調整大小的地圖:
要顯示 $('#showMap').on('shown', function() {
google.maps.event.trigger(businessMap, "resize");
});
我怎樣才能使標記chosenPoint
?
如果我錯過了任何信息,請讓我知道,我會添加它。
在此先感謝!
編輯:
var businessMap;
function showBusinessMap(x, y) {
var xops =
{
zoom: 15,
center: new google.maps.LatLng(x, y)
}
businessMap = new google.maps.Map(document.getElementById("businessMap"), xops);
var chosenPoint = new google.maps.Marker({
position: new google.maps.LatLng(x, y),
map: businessMap
});
}
還不行。
定義「不起作用」。我懷疑它工作得很好,你的地圖div沒有大小(至少它適用於本地副本)。 – geocodezip
http://www.geocodezip.com/v3_SO_simpleMap_businessMap.html – geocodezip