close ad
Help us test the new Databridge BETA with MySQLi support
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

code to move map to new center

Thread began 4/15/2010 3:17 pm by roger391472 | Last modified 3/14/2014 12:02 pm by roger391472 | 1901 views | 6 replies

roger391472

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.

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...