MichaelGayheart

GetMaxZoom for a point location?

Discussion created by MichaelGayheart on Aug 1, 2013
I am trying to create a simple javascript site that uses navigator.geolocation to get the user's current location and then centerAndZoom the map to that point as zoomed in as possible. My problem is that users from around the world would be expected to utilize this site to better share the exact location where they live, but basemaps aren't uniform around the world in terms of how far I can zoom in before I get "Map data not yet available".
Here is the code I have so far:
 if(navigator.geolocation){  
        navigator.geolocation.getCurrentPosition(zoomToLocation, locationError);
      }

     function zoomToLocation(location) {
      point = esri.geometry.geographicToWebMercator(new esri.geometry.Point(location.coords.longitude, location.coords.latitude));
      map.graphics.add(new esri.Graphic(point, markerSymbol));    
      map.centerAndZoom(point, 18);
    }


I would like to be able to do something like this:
function zoomToLocation(location) {
      point = esri.geometry.geographicToWebMercator(new esri.geometry.Point(location.coords.longitude, location.coords.latitude));
      map.graphics.add(new esri.Graphic(point, markerSymbol));
      //New code here: In places with good imagery, function might return 18, in places without good coverage, could return 12.
      scale = map.getMaxZoom(point)    
      map.centerAndZoom(point, scale);


Is there any way to accomplish this with existing api calls? There is a getMaxZoom() function (https://developers.arcgis.com/en/javascript/jsapi/map.html#getmaxzoom) but it doesn't take a point value.

Outcomes