谷歌地图API无法获得经度

时间:2009-12-01 02:45:06

标签: javascript google-maps

我正在尝试使用google maps api获取地址的经度和纬度,但我不知道该怎么做?这是我正在尝试的一个例子:

GoogleObjectAdress("New york") -> and it should return the longitude and latitude for me!

任何解决方案?

1 个答案:

答案 0 :(得分:1)

请尝试以下代码:

<script src="http://maps.google.com/maps?file=api&amp;v=2.x&amp;key=YourApiKey"
    type="text/javascript"></script>

var geocoder = new GClientGeocoder();
geocoder.getLatLng("New York", function(point) { 
    //code
});

有关详情,请参阅documentation