我想用這個手勢重建一個地圖,使用V2 api,通過http://marcgrabanski.com/。谷歌地圖v3自定義... v2很容易... v3有點爛
http://assets.marcgrabanski.com/resources/jquery-google-maps/tutorial-part1.html
但我想使用V3 API。但我覺得v3更多,也許不必要,更復雜,我想找到一個工作示例,開始構建在v3中。
有什麼建議嗎?
我想用這個手勢重建一個地圖,使用V2 api,通過http://marcgrabanski.com/。谷歌地圖v3自定義... v2很容易... v3有點爛
http://assets.marcgrabanski.com/resources/jquery-google-maps/tutorial-part1.html
但我想使用V3 API。但我覺得v3更多,也許不必要,更復雜,我想找到一個工作示例,開始構建在v3中。
有什麼建議嗎?
爲了證明gmaps API V3,我只是提出了一個小例子給你here。這只是基於您在帖子中提到的示例的非常規代碼。只需輸入座標將標記添加到地圖上,然後選擇特定的標記以顯示信息窗口。
代碼的主要部分
創作的地圖的
function initialize(){
var myOptions = {
zoom: 14,
center: new google.maps.LatLng(52.0, 62.0),
mapTypeId: google.maps.MapTypeId.ROADMAP
}
map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);
infowindow = new google.maps.InfoWindow(
{
size: new google.maps.Size(150,50)
});
google.maps.event.addListener(map, 'click', function() {
infowindow.close();
});
markersArray = [];
}
創建標記
function createMarker(latlng, html,zoom) {
var contentString = html;
var marker = new google.maps.Marker({
position: latlng,
map: map,
zIndex: Math.round(latlng.lat()*-100000)<<5
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.setContent(contentString);
infowindow.open(map,marker);
});
marker.MyZoom = zoom;
return marker;
}
的GOOGL e地圖api v3的設計要好得多,您可以查看一些其他樣本here。
也許你應該使用官方的例子,谷歌實際上提供:http://code.google.com/apis/maps/documentation/javascript/tutorial.html
你有這個工作嗎? – Philar 2010-11-22 19:21:43