I571/ChE531 2007 Class WikiMain Page | About | Help | FAQ | Special pages | Log in

Printable version | Disclaimers | Privacy policy

GoogleMapsExample

From I571/ChE531 2007 Class Wiki

<html>
<head>
<title>Where the I573 students are</title>
<script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAArOAa_mTw0tU3oZz9P4XIWRQkQdC6kUhxhkpt-CE9vKt7Bcx7GhTKL56QIbjxHPKhuOspPQXeTNVw9A" type="text/javascript"></script>
</head>
<body>
<p><strong>Where the I573 students are</strong></p>
<div id="map" style="width: 800px; height: 600px"></div>

<script type="text/javascript">

//<![CDATA[

// Create a new map

var map = new GMap2(document.getElementById("map"));
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.addControl(new GScaleControl());

var geocoder = new GClientGeocoder();


// Function to plot a name and address on the map (including converting to coordinates)

function showAddress(name, address)
{
  geocoder.getLatLng(
    address,
    function(point)
    {
      if (!point)
      {
        alert(address + " not found");
      }
      else
      {
        map.setCenter(point, 5, G_NORMAL_MAP);
	// Create marker
        var marker = new GMarker(point);
	// Make shown name when clicking on marker
	GEvent.addListener(marker, "click", function() {marker.openInfoWindowHtml(name);});
	// Add marker to map
        map.addOverlay(marker);
      }
    }
  );
}

// Access the database through PHP and plot markers


<?php
$link = mysql_connect("localhost", "root", "123456") or die("Could not connect: " . mysql_error());

$result = mysql_db_query(dwtestphp,"SELECT name,location FROM people;");
if (!$result)
{
  echo "no results ";
}
while($row = mysql_fetch_array($result))
{
  echo "showAddress(\"" . $row[0] . "\",\"" . $row[1] . "\");\n";
}
mysql_close($link);
?>
//]]>
</script>

</body>
</html>

Retrieved from "http://cheminfo.informatics.indiana.edu/djwild/i571wiki2007/index.php/GoogleMapsExample"

This page has been accessed 267 times. This page was last modified 14:00, 29 October 2007.


Find

Browse
Main Page
Community portal
Current events
Recent changes
Random page
Help
Donations
Edit
Edit this page
Editing help
This page
Discuss this page
Post a comment
Printable version
Context
Page history
What links here
Related changes
My pages
Log in / create account
Special pages
New pages
File list
Statistics
Bug reports
More...