Welcome to Geeklog, Anonymous Sunday, November 24 2024 @ 11:09 pm EST

Making a google map to go along with your articles

  • Wednesday, March 08 2006 @ 09:31 am EST
  • Contributed by: Anonymous
  • Views: 21,848
Geeklog You are blogging about your latest trip and you want everyone know where you actually went. You might want to link to google maps, but why make the people go away from your page if you can integrate Google maps on your page? This is how to do it:

1. Get a google maps key at http://www.google.com/apis/maps/signup.html
2. Create a static page and paste in the following code: ----------------------------
$code = "xxxxxxx";
$point_a = $_GET['point_a'];
$point_b = $_GET['point_b'];
$zoom = $_GET['zoom'];

?>

<script src="http://maps.google.com/maps?file=api&v=1&key=<;? echo $code; ?>" type="text/javascript"></script>

<div id="map" style="width:600px; height:400px"></div>
<script type="text/javascript">

//<![CDATA[

var map = new
GMap(document.getElementById("map"));
map.setMapType(G_SATELLITE_TYPE);
map.addControl(new GSmallMapControl());
map.centerAndZoom(new GPoint(<? echo $point_a . ',' . $point_b .'), '. $zoom;?>);

//]]>
</script>

<?
--------------------

3. Set the code in the first line (xxxxx) to the code you got from google.
4. Set the page to execute PHP (not return)
5.save it with the ID "maps"
6.now, if you can include links in your articles such as: http://example.com/staticpages/index.php/maps?point_a=114.155&point_b=22.285&zoom=1

change the zoom (larger is further away) and the coordinates to the point you want. you might need to download google earth to find the coordinates of your desired location.

Thats it!