Bing maps, how to make geocode request without call back in 7 version? -


i know how make bing geocode request callback function, this:

function makegeocoderequest(credentials)          {             var geocoderequest = "http://dev.virtualearth.net/rest/v1/locations/" + document.getelementbyid('txtquery').value + "?output=json&jsonp=geocodecallback&key=" + credentials;              callrestservice(geocoderequest);          }           function callrestservice(request)           {             var script = document.createelement("script");             script.setattribute("type", "text/javascript");             script.setattribute("src", request);             document.body.appendchild(script);          }          function geocodecallback(result)           {                // result          } 

(copied msdn maps ajax control 7.0 isdk)

in bing map 6.2 version opportunity make such request using next code:

map.find(null, tempdest, null, null, null, null, null, null, null, null,                                 function (a, b, c, d, e) { ... }); 

it useful because variables defined , ready use, in new version variables undefined , not want them global, know solution how make request without such callback?

looks version 7 doesn't support 6.x methods. here's example 7. example http://www.bingmapsportal.com/isdk/ajaxv7#searchmodule2

just added alert(topresult.location); line see location info.

function geocoderequest()  {      createsearchmanager();      var = 'denver, co';      var userdata = { name: 'maps test user', id: 'xyz' };      var request =      {          where: where,          count: 5,          bounds: map.getbounds(),          callback: ongeocodesuccess,          errorcallback: ongeocodefailed,          userdata: userdata      };      searchmanager.geocode(request);  }  function ongeocodesuccess(result, userdata)  {   if (result) {           map.entities.clear();          var topresult = result.results && result.results[0];          if (topresult) {              alert(topresult.location);             var pushpin = new microsoft.maps.pushpin(topresult.location, null);              map.setview({ center: topresult.location, zoom: 10 });              map.entities.push(pushpin);          }      }  }  function ongeocodefailed(result, userdata) {      displayalert('geocode failed');  }   if (searchmanager)  {      geocoderequest();  }  else  {      microsoft.maps.loadmodule('microsoft.maps.search', { callback: geocoderequest });  } 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -