Click to search on your search term.
Subscribe to Fig Leaf Tutorials

Need help with a project? Contact us at
From code reviews to project "jumpstarts" and full life-cycle development, we've got you covered!
Check out our case studies!
Follow us on Twitter!
Click here to join our Facebook group!

Ready to upgrade your skills? Try these instructor-led classes in Washington, DC:

Geocoding Addresses

Page of 168

You can translate an address into latitude/longitude coodinates through a process referred to as "geocoding." In the Google Maps API, geocoding is accomplished by invoking the google.maps.Geocoder() method as illustrated by the following code sample.

// instantiate the Geocoder class
var geocoder = new google.maps.Geocoder();

// define a sample street address + zip
var address = "1400 16th Street NW 20036";

// Instantiate a "please wait" message
Ext.Viewport.setMasked({xtype:'loadmask', message:'Please Wait...'});

// geocode the address
geocoder.geocode( { 'address': address }, function(results, status)
  if (status == google.maps.GeocoderStatus.OK) {
    var lat=results[0];
    var lng=results[0].geometry.location.lng();
    Ext.Msg.alert("Success!",lat + "," +lng);  

  // turn off please wait message

Note the following:

  • The geocoding service executes asynchronously, so you'll need to specify a handler function to capture the results from the service.
  • To communicate to the user that an async process is running, consider displaying a "loadmask" as illustrated by line 8
  • The geocoding service returns a results array and a status message. If the geocoding operation was successful, status will be equal to the constant google.maps.GeocoderStatus.OK.
  • The location of the address as a latitude,longitude point is available through results[0].geometry.location
Page of 168
comments powered by Disqus