使用V3 API编写代码。
function initialize ()
{
if (GBrowserIsCompatible())
{
var ch = new GLatLng (0,0);
var myOptions = {
zoom:7,
center: ch,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
map = new google.maps.Map(document.getElementById("map"), myOptions);
directionsDisplay = new google.maps.DirectionsRenderer(map, document.getElementById("map"));
directionsDisplay.setMap(map);
}
}
使用V2 API编写代码。
function initialize ()
{
if (GBrowserIsCompatible())
{
map = new GMap2 (document.getElementById("map"));
map.setCenter (new GLatLng(0,0),1 );
}
}
V2 API代码运行完美,V3 API代码没有显示任何地图。 我错过了什么要点吗?
编辑 已修改V3代码如下,但仍未显示地图:
var chicago = new google.maps.LatLng (0, 0);
var myOptions = {
zoom:1,
center: chicago,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
map = new google.maps.Map(document.getElementById("map"), myOptions);
<script src="http://maps.google.com/maps?file=api&v=2&key=GOOGLE_MAPS_KEY"
,我将其替换为 Trott 的这一行src="http://maps.google.com/maps/api/js?sensor=false"
,这起到了作用:mad: 感谢所有人的帮助。 - Aquarius_Girl