I have a Google map of four towns which I would like to centre to where the user aska.
This is accomplished by a simple nav bar, with the latitude and longitudes passed by an onClick function.
As is, the map won’t even show, but without the movemap function the map does nothing.
The code originally referred to Version 1 of the API, but I can’t understand where the errors are.
Can anyone help?
This is the code:
[CODE]<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>Home | THT Screening datasystem</title>
<script src=”http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAKGxWELolg102OCTz9kT2YBTidHo2lBGWodmjt0P4Tc60YUL9bRRxWvRFR_9Gdd9EvHBOAo5wZVWBYA&sensor=false”
type=”text/javascript”></script>
<script type=”text/javascript”>
function initialize() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById(“map_canvas”));
map.setCenter(new GLatLng(53.5157,-1.1327), 13);
}
}
function movemap(x,y) {
map.panTo(new GLatLng(parseFloat(x),parseFloat(y))), 5);
}
</script>
<link href=”css.css” rel=”stylesheet” type=”text/css” />
</head>
<body onload=”initialize()” onunload=”GUnload()”>
<center>
<div id=”container”>
<div id=”titlebar”>
<div id=”logo” style=”float:left;”>
<img src=”images/doncaster.gif” alt=”tht logo” />
</div>
<div id=”header”>
<h1>Welcome to THT <br />Doncaster’s data system.</h1>
This test system supports the Chlamydia screening programme in Doncaster, Rotherham, Barnsley and Bassetlaw, by tracking sessions and reporting results.
</div>
</div>
<div id=”nav”>
<?php include(“nav.php”); ?>
</div>
<div id=”location”>
<ul id=”setlocation” >
So where you at?
<li><a href=”#” onClick=”movemap(53.5537,-1.4791);”>Barnsley</a></li>
<li><a href=”#” onClick=”movemap(53.3096,-1.1227);”>Bassetlaw</a></li>
<li><a href=”#” onClick=”movemap(53.5157,-1.1327);”>Doncaster</a></li>
<li><a href=”#” onClick=”movemap(53.4301,-1.3572);”>Rotherham</a></li>
</ul>
</div>
<div id=”map_canvas” style=”width:730px;height:425px”>
</div>
</div>
</center>
</body>
</html>