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, "[email protected]" <[email protected]>
wrote:
> On Mar 16, 12:45 am, "[email protected]" <[email protected]>
> wrote:
>
> > On Mar 16, 12:40 am,caffeinated<[email protected]> 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.
>
>    -- Larry
>
>
>
>
>
> > > Or if I read
> > > correctly he is trying to sell his ideas?
>
> > > On Mar 16, 12:56 am, "[email protected]" <[email protected]>
> > > wrote:
>
> > > > On Mar 14, 5:28 pm,caffeinated<[email protected]> 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, [email protected] 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.
>
> > > > > > On Mar 8, 2011 4:37pm,caffeinated<[email protected]> wrote:
>
> > > > > > > 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.
> > > > > > > --
> > > > > > > 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  
> > > > > > > [email protected].
> > > > > > > To unsubscribe from this group, send email to  
> > > > > > > [email protected].
> > > > > > > For more options, visit this group at  
> > > > > > >http://groups.google.com/group/google-maps-js-api-v3?hl=en.

-- 
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Reply via email to