Yammyguy Posted April 23, 2009 Share Posted April 23, 2009 Hello all. I was just wondering if anyone has had any experience with google maps and inserting a simple google map image pointing out a user inputted address? Or does anyone know of a good tutorial for this type of activity? Thanks very much in advance, ~C. Quote Link to comment https://forums.phpfreaks.com/topic/155369-php-and-google-maps/ Share on other sites More sharing options...
JonnoTheDev Posted April 23, 2009 Share Posted April 23, 2009 Firstly get an API key from Google. Then read through the examples: http://code.google.com/apis/maps/documentation/examples/index.html Quote Link to comment https://forums.phpfreaks.com/topic/155369-php-and-google-maps/#findComment-817430 Share on other sites More sharing options...
kenrbnsn Posted April 23, 2009 Share Posted April 23, 2009 You also may want to look into using the Google Static Maps API For a good Google Maps API tutorial, you can use http://econym.org.uk/gmap/ Ken Quote Link to comment https://forums.phpfreaks.com/topic/155369-php-and-google-maps/#findComment-817441 Share on other sites More sharing options...
jonsjava Posted April 23, 2009 Share Posted April 23, 2009 here's a simple script to generate driving directions. I'm not sure it will help, but, hopefully it will: <?php $name = "John Doe"; $address = "1600 Pennsylvania Ave NW Washington DC"; ?> <h3>Directions to <?php print $name; ?></h3> <form name="form1"> Enter your address: <!-- input field where the user can enter the source address--> <input type="text" SIZE=40 MAXLENGTH=40 name="saddr" id="saddr" value="" /> <br> <!-- html button with a javascript function attached to it to show the directions in the iframe--> <INPUT value="Get Directions" TYPE="SUBMIT" onclick="javascript:GetDirections();return false;"> <BR> <BR> <!-- the iframe to show the directions, this is invisible when the page first loads, since the source attribute is empty --> <iframe id="mapframe" name="mapframe" src="" frameborder="0" width="640px" height="480px"> </iframe> </form> <script language="javascript"> function GetDirections() { var SourceAdress = 'saddr='; var DestinationAddress = 'daddr=<?php print $address;?>'; //hardcoded value for the destination address var Url = ''; //read out source adress from the input field SourceAdress += document.form1.saddr.value; //form the url Url = 'http://maps.google.com/maps?' + SourceAdress + '&' + DestinationAddress; // + '&output=html'; window.open(Url,'directions','width=1024,height=768,scrollbars=yes,toolbar=no,location=no, resizable=no'); } </script> </div> Quote Link to comment https://forums.phpfreaks.com/topic/155369-php-and-google-maps/#findComment-817449 Share on other sites More sharing options...
JonnoTheDev Posted April 23, 2009 Share Posted April 23, 2009 I'm not sure it will help It will help if you need to get to 1600 Pennsylvania Ave NW Washington DC Quote Link to comment https://forums.phpfreaks.com/topic/155369-php-and-google-maps/#findComment-817460 Share on other sites More sharing options...
jonsjava Posted April 23, 2009 Share Posted April 23, 2009 I'm not sure it will help It will help if you need to get to 1600 Pennsylvania Ave NW Washington DC lol. I just picked a easy-to-remember and well-known address. You can have that part filled in with a simple query. Quote Link to comment https://forums.phpfreaks.com/topic/155369-php-and-google-maps/#findComment-817465 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.