Does anyone know how to use javascript to zoom to a layer? I checked Layer object in client side API and did not see a function to get bounding box.
Thanks,
Wilson Jiang
Does anyone know how to use javascript to zoom to a layer? I checked Layer object in client side API and did not see a function to get bounding box.
Thanks,
Wilson Jiang
Hi Wilson,
Layer on the server side is an element for rendering an overlay which is not a part of the client side API. So we don't expose any API to access a Layer because it's impossible to maintain a layer on the client side. If so, the client view state will become too big which affects the client performance a lot.
We recommend to use callback to get the bounding box on the server side and pass it back to client; then call client API to implement this scenario.
Please see my attached sample and replace the same sample in our integrated samples; just feel free to let us know if you have more queries.
Thanks,
Howard
002_001_DisplayASimpleMap.zip (1.97 KB)
Hi Howard.
I want to zoom into a marker overlay "InMemoryMarkerOverlay" using JavaScript such that all the markers are rendered on the browser.
How do I do it?
Regards,
Anil
Hi Anil,
Regarding the MarkerOverlay, we can get the layer’s max extent which includes all of the markers on the client, because each marker is rendered as the icon with coordinate in browser. Here are some hints:
var map = Map1.GetOpenLayersMap();
var markerLayer = map.getLayer("id");
var markerLayerExtent = markerLayer.getDataExtent();
map.zoomToExtent(markerLayerExtent, true);
Thanks,
Johnny
Hi Johnny,
It will gives what browser has all markers in the overlay that are in view.
Looks I will need to get bounds information from the server.
Regards,
Anil
Hi Anil,
Yes. All the code posted previously works on the client and just gets the extent of markers in current view, if we would like to make sure all makers in overlay that are in view, we need to get the bounds from server, just as the sample provided by Howard.
Thanks,
Johnny