Geocoding confirmation

58 views
Skip to first unread message

caffeinated

unread,
Mar 8, 2011, 4:37:45 PM3/8/11
to Google Maps JavaScript API v3
I can't work out what to type into the search bar =( I have been
having problems working out where to get some detailed information on
how to achieve this:

I would like to first, use the geocoding service to place a marker on
an addressed location.
(ie. 32 Queen Street, Brisbane, QLD, 4000.)
Then I would like the user to be able to move the plotted marker into
a better location if the geocoder wasn't accurate enough.
Then I would like that marker's new location to be stored as lat lng
coordinates into my MySQL database.
I believe I found something on how to do this a while ago, but I can't
seem to work out what I searched any more.

Any web pages that you think may help me piece the puzzle together
would be greatly appreciated.

Regards,

S.

projec...@gmail.com

unread,
Mar 9, 2011, 1:59:25 PM3/9/11
to google-map...@googlegroups.com
Better and recommended way to do this is, have the geocoder only run once, write it to a db, then pull the latlong from the DB, speeds everything up, and doesn't gum up the geocoding service.

otherwise i have the code for exactly what you want to do.
> --
>
>
> You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group.
>
>
> To post to this group, send email to google-map...@googlegroups.com.
>
>
> To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.
>
>
> For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.
>
>
>
>
>
>

caffeinated

unread,
Mar 14, 2011, 8:28:06 PM3/14/11
to Google Maps JavaScript API v3
I was only intending on using the geocode service once. The idea would
be that it would find the address, plot a marker on a map, and then
the user could correct the position of the marker and then the new
position of the marker would be saved into the DB. If that is what you
have the code for, could you please fwd it on to me, or let me know
where I could get a sneak peak?

On Mar 10, 5:59 am, projectje...@gmail.com wrote:
> Better and recommended way to do this is, have the geocoder only run once,  
> write it to a db, then pull the latlong from the DB, speeds everything up,  
> and doesn't gum up the geocoding service.
>
> otherwise i have the code for exactly what you want to do.
>

geoco...@gmail.com

unread,
Mar 15, 2011, 9:56:14 AM3/15/11
to Google Maps JavaScript API v3
On Mar 14, 5:28 pm, caffeinated <sam.ja...@gmail.com> wrote:
> I was only intending on using the geocode service once. The idea
> would be that it would find the address, plot a marker on a map,
> and then the user could correct the position of the marker and then
> the new position of the marker would be saved into the DB. If that
> is what you have the code for, could you please fwd it on to me, or
> let me know where I could get a sneak peak?


http://groups.google.com/group/google-maps-js-api-v3/search?group=google-maps-js-api-v3&q=pinpointaddress&qt_g=Search+this+group

John Coryat's (v2) example:
http://maps.huge.info/pinpointaddress.htm

-- Larry

caffeinated

unread,
Mar 16, 2011, 3:40:10 AM3/16/11
to Google Maps JavaScript API v3
That is EXACTLY what I want to do. Except I don't see any links there
into how I could apply this code to my own website. Does Coryat offer
insite into how he achieved this result? Or if I read correctly he is
trying to sell his ideas?

On Mar 16, 12:56 am, "geocode...@gmail.com" <geocode...@gmail.com>
wrote:
> On Mar 14, 5:28 pm,caffeinated<sam.ja...@gmail.com> wrote:
>
> > I was only intending on using the geocode service once. The idea
> > would be that it would find the address, plot a marker on a map,
> > and then the user could correct the position of the marker and then
> > the new position of the marker would be saved into the DB. If that
> > is what you have the code for, could you please fwd it on to me, or
> > let me know where I could get a sneak peak?
>
> http://groups.google.com/group/google-maps-js-api-v3/search?group=goo...
>
> John Coryat's (v2) example:http://maps.huge.info/pinpointaddress.htm
>
>   -- Larry
>
>
>
>
>
> > On Mar 10, 5:59 am, projectje...@gmail.com wrote:
>
> > > Better and recommended way to do this is, have the geocoder only run once,  
> > > write it to a db, then pull the latlong from the DB, speeds everything up,  
> > > and doesn't gum up the geocoding service.
>
> > > otherwise i have the code for exactly what you want to do.
>

geoco...@gmail.com

unread,
Mar 16, 2011, 3:45:22 AM3/16/11
to Google Maps JavaScript API v3
On Mar 16, 12:40 am, caffeinated <sam.ja...@gmail.com> wrote:
> That is EXACTLY what I want to do. Except I don't see any links
> there into how I could apply this code to my own website. Does
> Coryat offer insite into how he achieved this result?

View source on the page?

-- Larry

geoco...@gmail.com

unread,
Mar 16, 2011, 3:49:44 AM3/16/11
to Google Maps JavaScript API v3
On Mar 16, 12:45 am, "geocode...@gmail.com" <geocode...@gmail.com>
wrote:
> On Mar 16, 12:40 am, caffeinated <sam.ja...@gmail.com> wrote:
>
> > That is EXACTLY what I want to do. Except I don't see any links
> > there into how I could apply this code to my own website. Does
> > Coryat offer insite into how he achieved this result?
>
> View source on the page?

Then translate it to v3 and connect it to your database.

caffeinated

unread,
Mar 20, 2011, 6:38:02 PM3/20/11
to Google Maps JavaScript API v3
I am missing a lot of the information required to do that as I am
completely new to Google Maps APIs. At the moment I am attempting to
just mark one location from a MySQL database just to do it all in baby
steps. I figure this is the first one I need to overcome. The URL of
the page I am attempting this on is:

http://www.caffeineauthority.com.au/app/map_search.php

The source is as follows:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?
sensor=false"></script>
<link rel="stylesheet" type="text/css" href="../css/map_search.css"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Check Location</title>
<? require('../php_incl/db_user_connect.php');
$query = ("SELECT * FROM cafe_info WHERE tl_id=1");
$go = mysql_query($query) or die(mysql_error());
$array = mysql_fetch_array($go);
if (!$array['address2']){
$address = $array['address1']." ".$array['suburb']." ".
$array['state']." ".$array['postcode'];
} else {
$address = $array['address1']." ".$array['address2']." ".
$array['suburb']." ".$array['state']." ".$array['postcode'];
}
$address = urlencode($address);
?>
<script type="text/javascript" src="http://maps.google.com/maps/api/
geocode/json?address=<? echo $address; ?>&sensor=false"></script>
<script type="text/javascript" src="../js/map_search.js">
</script>
</head>

<body onload="initialize()">
<h1>Check your address</h1>
<h2>Instructions:</h2>
<ol><li>Check to see if[marker_img] corresponds with the location of
your cafe.</li>
<li>If [marker_img] does not line up with the street location of your
cafe, use your mouse to move it into the right location.</li>
<li>Once [marker_img] is in the right position click [save] to
continue.</li></ol>
<p><? print $address; ?></p>
<div id="map_canvas"></div>
</body>
</html>

map_search.js:
var myLat = myJSONResult.results[0].geometry.location.lat;
var myLng = myJSONResult.results[0].geometry.location.lng;
function initialize(){
var myLatlng = new google.maps.LatLng(myLat,myLng);
var myOptions = {
zoom: 14,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);

var marker = new google.maps.Marker({
position: myLatlng,
map: map,
title:"Hello World!"
});
}

I cannot work out why it won't plot my marker on the location I have
searched. I have tested the search function, and it does give me a
result. But for some reason I am let down by:
var myLat = myJSONResult.results[0].geometry.location.lat;
var myLng = myJSONResult.results[0].geometry.location.lng;
For some reason this returns no results.
Am I placing that piece of code in the wrong location?

Regards.

On Mar 16, 6:49 pm, "geocode...@gmail.com" <geocode...@gmail.com>
wrote:
> On Mar 16, 12:45 am, "geocode...@gmail.com" <geocode...@gmail.com>
> wrote:
>

Rossko

unread,
Mar 20, 2011, 9:35:59 PM3/20/11
to Google Maps JavaScript API v3
> I cannot work out why it won't plot my marker on the location I have
> searched. I have tested the search function, and it does give me a
> result. But for some reason I am let down by:
>         var myLat = myJSONResult.results[0].geometry.location.lat;
>         var myLng = myJSONResult.results[0].geometry.location.lng;
> For some reason this returns no results.

Where in your script does anything assign any value to myJSONResult ?

Hint : you are using the wrong geocoding tool for the job. To geocode
client-side, use the client-side geocoder provided in the Maps API
http://code.google.com/apis/maps/documentation/javascript/services.html#Geocoding
Reply all
Reply to author
Forward
0 new messages