admin管理员组

文章数量:1335840

Here is my code for adding a image on openlayers map.

var image = new OpenLayers.Layer.Image(
    'Image 1',
    '.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. can anyone give me solution for this ?

Thanks in advance.

Here is my code for adding a image on openlayers map.

var image = new OpenLayers.Layer.Image(
    'Image 1',
    'http://belocalat./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. can anyone give me solution for this ?

Thanks in advance.

Share Improve this question edited Feb 14, 2013 at 13:19 urcm 2,2841 gold badge19 silver badges45 bronze badges asked Feb 13, 2013 at 7:14 TejasTejas 9282 gold badges16 silver badges40 bronze badges 2
  • why is the line setting bounds mented out? – olly_uk Commented Feb 13, 2013 at 10:56
  • if i remove ment it doesn't working.. have you any solution ? – Tejas Commented Feb 14, 2013 at 4:10
Add a ment  | 

1 Answer 1

Reset to default 3

i have tried following code and it has worked. check out from fiddle. dont forget to select Image layer from layerswitcher.

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

var graphic = new OpenLayers.Layer.Image(
    'Image',
    'http://belocalat./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...

本文标签: javascriptAdd image to openlayers mapStack Overflow