2

I'm using geoXMl3 to parse multiple kml files at a time. I'm getting polygons plotted on the map. when I click on the polygon an info-window pops up. I'm not getting from where this info-window is coming up My requirement is I want to edit the content of info-window through some java-script object

My java-script object will be like

popUpDetails = {'district-name':'content'}.

Not getting how to pass this in my parser

I have refered few links like:

https://code.google.com/p/geoxml3/wiki/Usage

and also how could I put data dynamically from database in infowindow of a certain polygon?

I'm parsing kml files this way:

var mapProp = {
    center: new google.maps.LatLng(51.508742,-0.120850),
    zoom: 5,
    mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("googleMap"), mapProp);
var parser = new geoXML3.parser({
    map: map,
    processStyles: true,
    zoom: false,
});

var infowindow = new google.maps.InfoWindow();
for (i = 0; i < ListofPathsofkmlfiles.length; i++) {
    parser.parse([ListofPathsofkmlfiles[i]]);      
}

Advance thanks for your help

Alok Agarwal
  • 3,071
  • 3
  • 23
  • 33
Vishal Mopari
  • 599
  • 7
  • 8

1 Answers1

1

I have finally figured out solution for same.

You need to overwrite createPolygon attribute of your parser for same.

var districtInfoMap = {doc_url1:infowindow_content1, doc_url2:infowindow_content2 };

var parser = new geoXML3.parser({
    createPolygon: mapDrawingToType(),
    map: map,
    processStyles: true,
    zoom: false,
    singleInfoWindow: true,
});

mapDrawingToType = function() {

    return function(placemark, doc) {
        var polygon = geoXML3.instances[geoXML3.instances.length-1].createPolygon(placemark, doc);

        if(polygon.infoWindow) {
            polygon.infoWindowOptions.content = districtInfoMap[doc.baseUrl];
    }
    return polygon;
}

}

Here I have made one object containing the map of district url and window content you have to show.

This will overwrite the default behavior of how your infowindow is displayed and the desired content you want to show will be displayed.

If you still face any issue please do let me know.

Alok Agarwal
  • 3,071
  • 3
  • 23
  • 33