peacehunter Posted January 17, 2011 Share Posted January 17, 2011 I want to add google map on my site using google map api and php. Where I could enter any address to a html form, and google map will display that based on my address which I have entered on a html form.Plzzz give me any suggestion , how to do this. Link to comment Share on other sites More sharing options...
justsomeguy Posted January 17, 2011 Share Posted January 17, 2011 Have you looked at the Google Maps API docs? Link to comment Share on other sites More sharing options...
thescientist Posted January 17, 2011 Share Posted January 17, 2011 Yup, what JSG said, and you would need something like cURL or the HTTP extension to complete the process of sending the form data in a URL format that the Google API will accept, and the take that response back and process it. Link to comment Share on other sites More sharing options...
justsomeguy Posted January 17, 2011 Share Posted January 17, 2011 You actually don't need PHP at all, Javascript could get the form data and send it to Google's services to display the map. I haven't looked into how Google does that without violating the ajax constraints (possibly submitting a form in an iframe), but it does work. Link to comment Share on other sites More sharing options...
thescientist Posted January 17, 2011 Share Posted January 17, 2011 ah yes, the iFrame solution would work. Link to comment Share on other sites More sharing options...
peacehunter Posted January 18, 2011 Author Share Posted January 18, 2011 Thnxxxxxxxx everybody for reply!!!!!!!! Link to comment Share on other sites More sharing options...
peacehunter Posted January 18, 2011 Author Share Posted January 18, 2011 Thnxxxxxxxx everybody for reply!!!!!!!! Link to comment Share on other sites More sharing options...
peacehunter Posted January 18, 2011 Author Share Posted January 18, 2011 I have found this code in google map api docs. I can not use it with html. The code is below: var map = new GMap2(document.getElementById("map_canvas"));var geocoder = new GClientGeocoder();function showAddress(address) { geocoder.getLatLng( address, function(point) { if (!point) { alert(address + " not found"); } else { map.setCenter(point, 13); var marker = new GMarker(point); map.addOverlay(marker); marker.openInfoWindowHtml(address); } } );} I used this html code : <form onsubmit="showAddress(this.address.value)" action="#"> <p> <input type="text" id="address" name="address" size="60"> <input type="submit" value="Go!"/> </p> <div id="map_canvas"></div> </form> Plzzz give me any suggestion about this problem.. Link to comment Share on other sites More sharing options...
justsomeguy Posted January 18, 2011 Share Posted January 18, 2011 Are you checking for Javascript errors? I think you're missing a couple things for the map configuration, I believe there are several required configuration values you need to pass. Where is the API documentation you're using? Link to comment Share on other sites More sharing options...
Synook Posted January 18, 2011 Share Posted January 18, 2011 Don't forget to actually load the Google Maps script, too. Also, that's API v2 code, which has been deprecated by Google in favor of version 3. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.