Select to view content in your preferred language

Bing Geocoder State of Alaska

846
3
04-12-2012 08:55 AM
JesseAdams
Occasional Contributor
I working on an application that uses the Bing Geocoder to return the best extent for a state and zoom to that location.  I'm finding an issue with the state of Alaska.  All of the other states return the correct spatial extent in the 'bestView' property.  Here is the code I have:

veGeocoder3.addressToLocations(where);//*** 'where' = 'AK' or 'Alaska'

function(geocodeResults) {
    
 if(geocodeResults.length == 0){
  alert("No address results returned.");
 }else if(searchType == 'Address' && radius != ''){
  var location = geocodeResults[0].location;
  var pointMeters = esri.geometry.geographicToWebMercator(location);
    var pointSymbol = new esri.symbol.SimpleMarkerSymbol().setSize(10).setColor(new dojo.Color("black"));
    var locationGraphic = new esri.Graphic(pointMeters,pointSymbol);
  var level = radiuszoom[radius];
  addResults.add(locationGraphic);
    var buffDist = radius;
    doBuffer(buffDist,pointMeters);        
    map.centerAndZoom(pointMeters,level);
 }else{
  map.setExtent(esri.geometry.geographicToWebMercator(geocodeResults[0].bestView));
 }
 
 });


Looking at the extent of the returned information I see the xmin value is missing a negative.  Has anyone experienced this same situation?  Any suggestions on a solution?  I would still like to stick with the Bing Geocoder instead of publishing a state layer for searching.  Thanks!
0 Kudos
3 Replies
JeffPace
MVP Alum
If you include the aleutian islands, Alaska crosses the international dateline, so 170 is most likely correct.

I working on an application that uses the Bing Geocoder to return the best extent for a state and zoom to that location.  I'm finding an issue with the state of Alaska.  All of the other states return the correct spatial extent in the 'bestView' property.  Here is the code I have:

veGeocoder3.addressToLocations(where);//*** 'where' = 'AK' or 'Alaska'

function(geocodeResults) {
    
 if(geocodeResults.length == 0){
  alert("No address results returned.");
 }else if(searchType == 'Address' && radius != ''){
  var location = geocodeResults[0].location;
  var pointMeters = esri.geometry.geographicToWebMercator(location);
    var pointSymbol = new esri.symbol.SimpleMarkerSymbol().setSize(10).setColor(new dojo.Color("black"));
    var locationGraphic = new esri.Graphic(pointMeters,pointSymbol);
  var level = radiuszoom[radius];
  addResults.add(locationGraphic);
    var buffDist = radius;
    doBuffer(buffDist,pointMeters);        
    map.centerAndZoom(pointMeters,level);
 }else{
  map.setExtent(esri.geometry.geographicToWebMercator(geocodeResults[0].bestView));
 }
 
 });


Looking at the extent of the returned information I see the xmin value is missing a negative.  Has anyone experienced this same situation?  Any suggestions on a solution?  I would still like to stick with the Bing Geocoder instead of publishing a state layer for searching.  Thanks!
0 Kudos
JesseAdams
Occasional Contributor
That makes sense.  I don't remember this being the case a few months back.  Why would the "bestview" return values that don't best represent the "bestview" of the spatial feature being requested.  I suppose using the the returned location point would be an option?  Any other options?
0 Kudos
JeffPace
MVP Alum
That makes sense.  I don't remember this being the case a few months back.  Why would the "bestview" return values that don't best represent the "bestview" of the spatial feature being requested.  I suppose using the the returned location point would be an option?  Any other options?


no idea, you could try setExtent(...extent.bestview, true) to force the entire extent into the view.
0 Kudos