2011-03-18 177 views
1

這裏我想顯示這個緯度的針(標記)點位置地址?在這裏,我發送一箇中心,我還必須向API發送兩個或更多中心(latlng)並獲得更多標記位置。在地圖中放置位置標記?

的jQuery:

var map; 
var geocoder; 
var address; 

function initialize() { 
    map = new GMap2(document.getElementById("map_canvas")); 
    map.setCenter(new GLatLng(13.0423734,80.2727993), 10); 
    map.setUIToDefault(); 
    geocoder = new GClientGeocoder(); 
} 

HTML:

<body onload="initialize()"> 
    <div id="map_canvas" style="height:550px; width:950px"> 
    </div> 
    </body> 

在那裏我有這樣的代碼:

map.setCenter(point, 13); 
    var marker = new GMarker(point); 
    map.addOverlay(marker); 
+2

我的第一個建議是,如果您還沒有深入到Google地圖項目,儘可能將其從已棄用的庫升級到v3。 [請參閱v3參考資料](http://code.google.com/apis/maps/documentation/javascript/)。 – lsuarez 2011-03-18 07:19:11

+0

我想爲這個latlng ..map.setCenter找到泡泡(new GLatLng(13.0423734,80.2727993),10); – selladurai 2011-03-18 07:32:34

回答

1
var map; 
var geocoder; 
var address; 

function initialize() { 
    map = new GMap2(document.getElementById("map_canvas")); 
    map.setCenter(new GLatLng(13.0423734,80.2727993), 10); 
    map.setUIToDefault(); 
    geocoder = new GClientGeocoder(); 
} 


function showAddress(address) { 
    geocoder.getLatLng(
    address, 
    function(point) { 
     if (!point) { 
     alert(address + " not found"); 
     } else { 
     map.setCenter(point, 13); 
     var marker = new GMarker(point); 
     map.addOverlay(marker); 
     } 
    } 
); 
} 

資源: http://code.google.com/apis/maps/documentation/javascript/v2/services.html#Geocoding