1

我正在使用 OpenLayers 开发一个地图项目,我想在谷歌图像底图上显示街道数据。ESRI 通过他们的 ArcGIS REST 服务器提供了一个很好的街道叠加层,但我无法让 OpenLayers 加载它。我试过按照文档和这个示例进行操作,但无法弄清楚我在做什么不同的事情,这使它不起作用。它将与 Google 卫星底图一起在图层面板中放置一个新图层,但该图层中没有加载任何内容——它是空白的。这是我的代码:

function addOpenLayers() {
    var mapcenter = new OpenLayers.LonLat(-90.8, 46.45)
    var base = new OpenLayers.Layer.Google("Google Satellite", {type: google.maps.MapTypeId.SATELLITE, numZoomLevels:22});

    var olOptions = {
        controls: [new OpenLayers.Control.PanZoomBar, new OpenLayers.Control.LayerSwitcher, new OpenLayers.Control.Navigation],
    }
    var olMap = new OpenLayers.Map("map", olOptions);

    olMap.addLayer(base);

    olMap.setCenter(mapcenter.transform(
        new OpenLayers.Projection("EPSG:4326"),
        olMap.getProjectionObject()
    ), 10);

    //This is the part that doesn't work:
    var esriRoadsUrl = "http://server.arcgisonline.com/ArcGIS/rest/services/Reference/World_Transportation/MapServer";
    var esriRoads = new OpenLayers.Layer.ArcGIS93Rest("Roads", esriRoadsUrl, {layers: "show:0"});
    esriRoads.isBaseLayer = false;

    olMap.addLayer(esriRoads);
}
4

0 回答 0