【发布时间】:2015-11-18 07:50:44
【问题描述】:
自去年以来,我一直在我的应用程序中使用谷歌地图图层,但它突然停止工作。我们需要使用谷歌地图 API 的密钥吗?我的代码如下。
map = new OpenLayers.Map('mapDiv');
map.addControl(new OpenLayers.Control.LayerSwitcher());
var gphy = new OpenLayers.Layer.Google(
"Google Physical",
{type: google.maps.MapTypeId.TERRAIN}
);
var gmap = new OpenLayers.Layer.Google(
"Google Streets", // the default
{numZoomLevels: 20}
);
var ghyb = new OpenLayers.Layer.Google(
"Google Hybrid",
{type: google.maps.MapTypeId.HYBRID, numZoomLevels: 20}
);
var gsat = new OpenLayers.Layer.Google(
"Google Satellite",
{type: google.maps.MapTypeId.SATELLITE, numZoomLevels: 22}
);
map.addLayers([gphy, gmap, ghyb, gsat]);
// Google.v3 uses EPSG:900913 as projection, so we have to
// transform our coordinates
map.setCenter(new OpenLayers.LonLat(10.2, 48.9).transform(
new OpenLayers.Projection("EPSG:4326"),
map.getProjectionObject()
), 5);
我已经插入了所有必要的脚本库。如果一旦我选择 Google 卫星,然后尝试使用 Google 街道或 Maps 以外的其他选项,请在应用程序上加载。
【问题讨论】:
-
我们面临同样的问题。我也尝试过使用 OpenLayers 中的示例,所以谷歌似乎发生了一些变化。
-
@Staale 我在那里查看过,他们昨天没有修补任何东西,最后一次发布是在 11 月 10 日。
-
@HiteshVaghani 他们已经通知他们将在 17 日或之后不久做一些事情 - 如果这是否相关,或者更改已经完成,我不能说:groups.google.com/forum/#!topic/google-maps-js-api-v3-notify/…
标签: javascript google-maps maps openlayers