Jump to content

how to add google map to a website using php and google map api


peacehunter
 Share

Recommended Posts

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

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

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...