I have got a file which overlays the state of New South Wales' electoral boundaries onto a Google Map. The markers which popup on each electorate really interfere with the visuals of the map when zoomed out. I have found how to disable the info window, but can't work out how to turn the markers off all together.
Map example is here:
http://www.codepress.com.au/nsw_lower_house_map.html
With markers tur开发者_开发技巧ned off, is there then a way to make the whole electorate polygon clickable to work with in JS?
To make polygons clickable bind an event listener to a layer after you add layer to the map
ctaLayer.setMap(map);
google.maps.event.addListener(ctaLayer, 'click', function(kmlEvent) {
var text = kmlEvent.featureData.name;
alert(text);
})
The above will alert the name of the feature that you clicked on (providing the name is set in KML). PLEASE NOTE: for polygons to be "usefully" click able they need a fill to be set. Your KML file does not have the fill so the only area click able will be the border of the polygon. You will need to set the fill to make this feature useful.
In general The KML feature object returns the following data:
{
author: {
email: "nobody@google.com",
name: "Mr Nobody",
uri: "http://example.com"
},
description: "description",
id: "id",
infoWindowHtml: "html",
name: "name",
snippet: "snippet"
}
Again - providing these are set in KML
To get rid of the markers you will need to modify the KML and remove all Placemarks and their containing Folder which have no polygons specified in them - only Point data (which is rendered as a marker). Make sure you re-validate your XML after deletion.
Here is your file without the markers http://www.mediafire.com/?f9ewd0c5ymk3ccv . However you will need to make sure that your polys have fill set otherwise you will only be able to click on the borders.
精彩评论