Creating a map - need to place markers on from xml or kml feed?

Associate
Joined
18 May 2006
Posts
785
I'm creating a map like a Google Map and would like it to populate with markers in a similar way to how Google does it.. ie from an external file like a xml file.. however Google call their method KML Architecture.

Has anyone done this before or can anyone shed any helpful light please.


Other things on my list are:

Limit number of markers displayed until your at a certain zoom level (so its not over crowded when looking at the whole of England for example).

And also having a min and max zoom level.

Cheers
 
Last edited:
I'm currently also looking at doing something like this. Not to hijack the thread but has anyone done it successfully with OpenStreetMap?

I've read the Wiki etc but never actually seen one in real use.
 
You're not passing the image through as part of the MarkerOptions

Code:
function createMarker(name, latlng) {
    var marker = new google.maps.Marker({
        position: latlng,
        map: map, 
        [B]icon:'http://www.alexhaworth.co.uk/test/pin.png'[/B]
    });

    google.maps.event.addListener(marker, "click", function() {
        if (infowindow)
            infowindow.close();
        infowindow = new google.maps.InfoWindow({content: name});
        infowindow.open(map, marker);
    });
    return marker;
}

You need to pass it through as part of the options, then it will work as expected.
 
Thanks mate that's really helpful - I have one final question if you wouldn't mind lending your expertise.

When the maps zoomed out I'd like it to cluster the markers together, I've found this code but unsure where to put it also as it looks like it shares long and lat details that have already been set in the code?

http://gmaps-utility-library.googlecode.com/svn/trunk/markerclusterer/1.0/docs/examples.html

just looking at the simple:

var map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(37.4419, -122.1419), 13);
var mc = new MarkerClusterer(map);
 
I've not used the MarkerCluster functionality myself so can't really offer anymore help other than what is stated in the API docs.

However if you are only wanting to do this when zooming you will need to observe the zoom_changed event for the map and then trigger the MarkerCluster functionality as you see fit.

http://code.google.com/apis/maps/documentation/javascript/events.html#EventsOverview

I may actually have a play with MarkerClusters myself shortly as it's always been needed on http://labs.phunky.co.uk/geo/
 
No problems at all mate, It's my first look at API's and I'm not from a codey background so struggling more than I'd hoped. Your site looks good.

Another question (sorry) can you point me to the right documentation to change the text from displaying in a pop up box to just a label that comes up under the icon when clicked (I think its defaultly referred to as its title and im currently using name for the popup box
 
Back
Top Bottom