【发布时间】:2013-03-19 23:05:23
【问题描述】:
我正在使用下面的 google maps api v2 在地图上的 var address 行中显示地址,我想在 api v3 中使用它。有谁知道如何将其制作为 google maps api v3?
<script type="text/javascript">
//<![CDATA[
var geocoder;
var map;
var address = "425 West 53rd St,New York,NY,";
// On page load, call this function
function load()
{
// Create new map object
map = new GMap2(document.getElementById("map"));
map.addControl(new GSmallMapControl());
// Create new geocoding object
geocoder = new GClientGeocoder();
// Retrieve location information, pass it to addToMap()
geocoder.getLocations(address, addToMap);
}
// This function adds the point to the map
function addToMap(response)
{
// Retrieve the object
place = response.Placemark[0];
// Retrieve the latitude and longitude
point = new GLatLng(place.Point.coordinates[1],
place.Point.coordinates[0]);
// Center the map on this point
map.setCenter(point, 15);
// Create a marker
marker = new GMarker(point);
// Add the marker to map
map.addOverlay(marker);
} //]]>
</script>
<script src="http://maps.google.com/maps?file=api&v=2&key=xxxxxxxx" type="text/javascript"></script><div id="map"></div>
【问题讨论】:
-
您是否尝试过查看the documentation for the v3 geocoder,以及其中包含的"simple" example?
-
我已经看了几个小时的文档和示例。他们没有帮助。他们所有的例子都带有输入字段。我需要直接在代码中添加地址,就像我的 v2 示例一样。我不是程序员,所以我在这里寻求帮助。
标签: google-maps google-maps-api-3 google-maps-api-2