More

Restricting zoom levels based on Bing Map availability?


My site is built on ArcGIS Server 10 with the JavaScript API 2.3, and uses Bing Maps as the background mapping. Although the site is aimed at NSW, Australia we allow the user to zoom anywhere in the world, at any of the supported scales (ie, the tiling scheme as specified in the ArcGIS Help File.)

Bing Maps road/satellite datasets are available at varying scale ranges, with populated areas supporting larger scales than empty rural areas. When zooming somewhere with no map/satellite data, a "broken camera" icon is shown. We'd like to avoid showing this ugly icon.

How can we restrict the maximum zoom scale where the map/satellite is not available, but allow full zoom-in where it is available?

Google Maps does this quite well - as you move around the world you can see the Zoom Slider expand/contract depending on what datasets are available at that location. They presumably have metadata showing the presence/absence of data, so we seek emulate this when using Bing Maps, with no access to the metadata.


Bing Maps is a tiled map, so has levels of detail when zoomed in or out. I would fire a conditional statement on every extent change. Something like: event fired: Extent Change Conditional: if map style = aerial and (get level < desired): set level back at desired…


Before zooming to a location, perhaps get the image metadata to see what the finest resolution is available there.

Determine the availability of imagery at a location at a specified zoom level

Since the response contains zoomMin and zoomMax, I suppose you could make the call just once at a low res zoom level and use the values from that, otherwise it seems like you might need to make multiple calls.


function getMapServerMetadata(Url) { var metadata = ""; esri.request({ url: Url + "?f=json", handleAs: "json", callbackParamName: "callback", load: function (response, io) { metadata += "Map Name: " + response.mapName; metadata += "

Current Version: " + response.currentVersion; metadata += "

Service Description: " + response.serviceDescription; metadata += "

Copyright: " + response.copyrightText; metadata += "

Number of Layers: " + response.layers.length; metadata += "

Number of Tables: " + response.tables.length; metadata += "

Spatial Reference: " + response.spatialReference.wkid; alert(metadata); }, error: function (error) { alert(error.message); } }); } // Available json objects // currentVersion // serviceDescription // mapName // description // copyrightText // layers // tables // spatialReference // singleFusedMapCache // tileInfo // initialExtent // fullExtent // units // supportedImageFormatTypes // documentInfo // capabilities // _ssl

e.g. try using the above code with a regular basemap MapServer url from ESRI like: http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer

you can also use this on sublayers as well - to find out what metadata is there just use the base url and add ?f=json to have a json representation returned and iterate through the field names.


Watch the video: Bing Map in Windows App (September 2021).