/    Sign up×
Community /Pin to ProfileBookmark

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&amp;v=2&amp;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>
[/CODE]

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @AliHurworth spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...