Hi ThinkGeo,
I want to zoom into a marker using JavaScript API. I have the Marker ID. How to do it?
Regards,
Anil
Hi ThinkGeo,
I want to zoom into a marker using JavaScript API. I have the Marker ID. How to do it?
Regards,
Anil
Anil,
There are three things left to implement your requirement.
1. Get the marker object from the related Markers layer;
2. Get the lonlat object from the marker;
dev.openlayers.org/releases/OpenLayers-2.10/doc/devdocs/files/OpenLayers/Marker-js.html
3. Call the setCenter or zoomToExtent method of map object in order to zoom into a marker.
dev.openlayers.org/releases/OpenLayers-2.10/doc/devdocs/files/OpenLayers/Map-js.html
Thanks,
Khalil
Hi Khailil,
For some reasons I cannot get it to work
How do set the Bounds object ?
I have the LongLat from the marker. I call it to include in the longlat object. How do I set the width and height?
var extent = new OpenLayers.Bounds ()
Regards,
Anil
Anil,
The usage of marker is blow, you can set width and height according to it.
var markers = new OpenLayers.Layer.Markers( "Markers" );
map.addLayer(markers);
var size = new OpenLayers.Size(21,25);
var offset = new OpenLayers.Pixel(-(size.w/2), -size.h);
var icon = new OpenLayers.Icon('openlayers.org/dev/img/marker.png', size, offset);
markers.addMarker(new OpenLayers.Marker(new OpenLayers.LonLat(0,0),icon));
markers.addMarker(new OpenLayers.Marker(new OpenLayers.LonLat(0,0),icon.clone()));
Here is the bounds documentation for detail.
dev.openlayers.org/releases/...ers.Bounds
Thanks,
James