如何在openstreetmap上叠加图像?

时间:2019-04-22 13:46:35

标签: javascript openlayers openstreetmap

我正在尝试将图像叠加在Openstreetmap上。

我从他们的网站(https://wiki.openstreetmap.org/wiki/Die_HTML_Dateien)使用了示例,并尝试在某些坐标处添加图像:

  `function drawmap()
    {       
        OpenLayers.Lang.setCode('de');

        map = new OpenLayers.Map('map',
    {
            
            projection: new     OpenLayers.Projection("EPSG:900913"),
            displayProjection: new     OpenLayers.Projection("EPSG:4326"),
            controls: [
                new     OpenLayers.Control.Navigation(),
                new     OpenLayers.Control.LayerSwitcher(),
                new     OpenLayers.Control.PanZoomBar()],
            maxExtent:
                new     OpenLayers.Bounds(-20037508.34, -20037508.34,
                    20037508.34, 20037508.34),
            numZoomLevels: 18,
            maxResolution: 156543,
            units: 'meters',           
        });      

        layer_basic = new OpenLayers.Layer.OSM("Basic");

        var graphic = new OpenLayers.Layer.Image(
            'Image',
            'https://cdn2.iconfinder.com/data/icons/Qetto___icons_by_ampeross-d4njobq/256/jpg.png',
            new OpenLayers.Bounds(15.419198532265034, 47.07662635844666, 15.421042606244283, 47.07661959417825),
            new OpenLayers.Size(256, 256),
            {
                isBaseLayer: false,
                visibility: true,
                displayInLayerSwitcher: true
            }

            );

        map.addLayers([layer_basic, graphic]);
    }

它不起作用,我不知道为什么... 我要使用的图片的尺寸为EPSG:3857和2000x2000。代码中的图片只是随机的。

目标是将飞机拍摄的图片覆盖整个城市,因此,如果您知道我的意思,那么我将OpenStreetMap图层放在图像图层的下面。

使用上面的代码,图像层变灰并检查。

谢谢您的建议!

0 个答案:

没有答案