Re: How To: Geocoding, Google Maps and street addresses (strings)

1,509 views
Skip to first unread message
Message has been deleted

Libby

unread,
Jun 15, 2011, 8:02:47 PM6/15/11
to Eclipse Plugin for PhoneGap
(reply w/same content but formatted nicely)

Someone had asked about using a street address
("10 main st, mayberry...") in a direction request.
Here's the long version of an answer:

Using the jQuery Google Map Plugin (the same plugin
used in TMT4P1 and GMap Demo), you simply put the
address string value for origin or destination: (see
"345 Healdsburg Avenue, Healdsburg, CA, USA")

function(position) {
$('#map_canvas').gmap('displayDirections',
{ 'origin' : new google.maps.LatLng(position.coords.latitude,

position.coords.longitude),
'destination' :
"345 Healdsburg Avenue, Healdsburg, CA, USA",
'travelMode' :
google.maps.DirectionsTravelMode.DRIVING} . . .

The displayDirections request will geocode the string to a
lat/lng object and compute directions (above snipped from
success callback giving 'position').

IMPORTANT: In order to fully understand Google Maps
Geocoding, it is highly recommended to read about the
TWO WAYS of using geocoding:

1. For dynamically created addresses (user input of address,
not known ahead of time):

Google Maps JSAPI v3 Client Geocoder (Geocoding Request):
http://code.google.com/apis/maps/documentation/javascript/services.html#Geocoding

In the plugin, this method is also used in the gmap 'search'
Geocoder Request.

2. For statically known addresses (like mapping markers for
businesses):

The Google Geocoding API:
http://code.google.com/apis/maps/documentation/geocoding/index.html

Especially this part:
http://code.google.com/apis/maps/documentation/geocoding/index.html#Audience

"Geocoding is a time and resource intensive task. Whenever possible,
pre-geocode known addresses (using the Geocoding API described here or
another geocoding service), and store your results in a temporary
cache of your own design."
Reply all
Reply to author
Forward
0 new messages