Jump to content

Google Map Default Lat and Long


erme

Recommended Posts

Hi,

 

I have a database of different uk addresses and a separate field for counties. on the webpage a user can click on a county name and the google map will display all the addresses of only that county. All works fine and dandy.

 

Currently the map only displays the default Lat and Long I have entered. The question is, how would I go about making the map display the county so that the user doesn't have to scroll to the county to view the addresses displayed.

 

Here is the code that specifies the 'default' location for the map upon load/refresh:

 

function load() 
{ 
    if (GBrowserIsCompatible())
    {
        var map = new GMap2(document.getElementById("map"));
        map.addControl(new GSmallMapControl());
        map.addControl(new GMapTypeControl());
        map.setCenter(new GLatLng(50.389496, -4.748574), ;
        GDownloadUrl("/includes/locations.php",
            function(data)
            {
                var xml = GXml.parse(data);
                var markers = xml.documentElement.getElementsByTagName("marker");
                for (var i = 0; i < markers.length; i++)
                {
                    var Name = markers[i].getAttribute("Name");
                    var Address = markers[i].getAttribute("Address");
                    var Tel = markers[i].getAttribute("Tel");
                    var point = new GLatLng(parseFloat(markers[i].getAttribute("Lat")),parseFloat(markers[i].getAttribute("Long")));
                    var marker = createMarker(point, Name, Address, Tel);
                 map.addOverlay(marker);
                }
            });
    }
}

 

Link to comment
https://forums.phpfreaks.com/topic/173002-google-map-default-lat-and-long/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.