perficut Posted December 25, 2006 Share Posted December 25, 2006 You guys have been a huge help lately and although I like to try and figure things out myself since for me atleast, its a great way to learn and retain. However, Im just stuck. Heres what I have.Simple page, loads a map automatically based on the lat/long co-ordinates. Then using a form input, grabs the lat/long co-ords of the new address and displays a map using that info.I'd like to put this final code into a php file which already has a number of data fields being passed into it, of which is $street $city $zip Since this is the case, can we eliminate the form field here, but still have the action still take place using the above data fields. This way, the page will automatically get the long/lat co-ords of the $street $city $zip which is passed in from a previous form, and display the appropriate map. [code]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> <title>Google Maps API Example - Geocoding API</title> <script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAzcL9hcXWFSlgOlWZDTLn6hRevAYoGCHvlUG86GujGYzhd2HRrBSSDfr44HxVmYLuH7RbNstxAlBfdQ" type="text/javascript"></script> <script type="text/javascript"> //<![CDATA[ var map = null; var geocoder = null; function showAddress(address) { if (geocoder) { geocoder.getLatLng( address, function(point) { if (!point) { alert(address + " not found"); } else { map.setCenter(point, 18); var marker = new GMarker(point); map.addOverlay(marker); marker.openInfoWindowHtml(address); } } ); } } //]]> function load() { if (GBrowserIsCompatible()) { map = new GMap2(document.getElementById("map")); map.setCenter(new GLatLng(37.4419, -122.1419), 13); map.setMapType(G_SATELLITE_TYPE) geocoder = new GClientGeocoder(); } } </script> </head> <body onload="load()" onunload="GUnload()"> <form action="#" onsubmit="showAddress(this.address.value); return false"> <p> <input type="text" size="60" name="address" value="368 clover court glen burnie md 21060" /> <input type="submit" value="Go!" /> </p> <div id="map" style="width: 500px; height: 500px"></div> </form> </body></html>[/code] In other words.....Since I already have the data coming ito this file alread in $street $city and $zip fields. I'd like the program to display the map using that info, instead of displaying a default map using the co-ordinates 37.4419, -122.1419 , then asking for the address again, in order to display the right map. Link to comment https://forums.phpfreaks.com/topic/31801-help-getting-this-google-map-to-automatically-grab-latlong/ Share on other sites More sharing options...
redarrow Posted December 25, 2006 Share Posted December 25, 2006 http://www.phpinsider.com/php/code/GoogleMapAPI/ Link to comment https://forums.phpfreaks.com/topic/31801-help-getting-this-google-map-to-automatically-grab-latlong/#findComment-147485 Share on other sites More sharing options...
perficut Posted December 25, 2006 Author Share Posted December 25, 2006 Thats where I started. Spent hours trying to decipher their codes and understand their terminology. Also, why I am working with the simplest of their examples and trying to manipulate it to do what I want. Link to comment https://forums.phpfreaks.com/topic/31801-help-getting-this-google-map-to-automatically-grab-latlong/#findComment-147531 Share on other sites More sharing options...
perficut Posted December 26, 2006 Author Share Posted December 26, 2006 anyone? Link to comment https://forums.phpfreaks.com/topic/31801-help-getting-this-google-map-to-automatically-grab-latlong/#findComment-147745 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.