Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add image to openlayers map

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

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. can anyone give me solution for this ?

Thanks in advance.

like image 995
Tejas Avatar asked Oct 22 '22 17:10

Tejas


1 Answers

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.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...

like image 112
Aragon Avatar answered Oct 24 '22 11:10

Aragon