code to move map to new center
I'm working on a map that displays the entire US on open but then when a "state" link is clicked I want it to pan and zoom to the state that was clicked. I've listed the state centers and their respective zoom levels in an xml file called states.xml This is my first use of javascript and GoogleMaps and I'm having trouble figuring this out.
Here's the link to the site: index.php To see the page I'm working on click on the "Tracks" button at the top of the page. There's also a details page if you click on one of the states and then click on one of the tracks. It's track_details.php but I used ProMaps on it and everything is working perfectly in it. When I tried to use the ProMaps on the race_track_directory.php page though I couldn't get it to work. It seemed to be a code conflict with the recordset on that page. I had to take out the WHERE statement to get it to work and then of course the "states" links and my repeating region for the tracks didn't work. I tried using DA Search, a second recordset and concatenating the WHERE statement but couldn't anywhere with it. So now I've gone back to just the regular GoogleMaps API code and I'm outputting the xml with phpsqlajax_genxml.php All of the xml is working fine for the markers.
Currently I'm getting a "trkstate is not defined" in Firebug and the map isn't moving at all.
Here's the javascript that I'm trying to use. The gup function was a function that I found in a search that is supposed to pull the url parameter.
function gup( trkstate )
{
trkstate = trkstate.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+trkstate+"=([^&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec( window.location.href );
if( results == null )
return "";
else
return results[1];
GDownloadUrl("states.xml", function(data, responseCode) {
alert(data);
});
var trkstate_param = gup( 'trkstate' );
function animate() {
map.panTo(new GLatLng("stlat", "stlong"));
var getstate = xml.documentElement.getElementsByTagName("statezoom");
var panpoint = new GLatLng(parseFloat(statezoom.getAttribute("stlat")),
parseFloat(statezoom.getAttribute("stlong")));
}
}
I'd really appreciate it if someone could head me in the right direction. Let me know if you need me to post any of the code or anything.
Thanks in advance.