简体   繁体   English

将图像添加到openlayers地图

[英]Add image to openlayers map

Here is my code for adding a image on openlayers map. 这是我在openlayers地图上添加图片的代码。

var image = new OpenLayers.Layer.Image(
    'Image 1',
    'http://belocalat.com/wp-content/plugins/openlayers/data/baselayer-img1.png',
    //new OpenLayers.Bounds(27.418100,35.771100,28.388000,36.558500),
    new OpenLayers.Size(800,255),
    {isBaseLayer: false}
 );

map.addLayer(image);

but, i can't display image on openlayers. 但是,我无法在openlayers上显示图像。 can anyone give me solution for this ? 谁能给我解决这个问题?

Thanks in advance. 提前致谢。

i have tried following code and it has worked. 我试过以下代码,它已经有效了。 check out from fiddle . 小提琴看 dont forget to select Image layer from layerswitcher. 别忘了从layerswitcher中选择Image layer。

var osm = new OpenLayers.Layer.OSM();

var graphic = new OpenLayers.Layer.Image(
    'Image',
    'http://belocalat.com/wp-content/plugins/openlayers/data/baselayer-img1.png',
    new OpenLayers.Bounds(27.418100,35.771100,28.388000,36.558500),
    new OpenLayers.Size(800,255),
    {numZoomLevels: 3}
);

map.addControl(new OpenLayers.Control.LayerSwitcher());
map.addLayers([osm, graphic]);
map.zoomToExtent(new OpenLayers.Bounds(27.418100,35.771100,28.388000,36.558500));

i hope it helps you... 我希望它可以帮助你......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM