0

I'm using jquery plugin gmap3 and am using a kmllayer. how can get markers from kml?. I need to filter the markers by regions

jdnichollsc
  • 1,520
  • 1
  • 24
  • 44

2 Answers2

1

You can't access the markers in a KmlLayer (it is rendered as map tiles by Google's servers). You could use a FusionTableLayer (you can import KML into the FusionTable, then modify the query to that FusionTable to filter the markers) or a third party KML parser like geoxml3 or geoxml-v3 (which render the KML using native Google Maps v3 objects). Not sure if any of them work with gmap3.

geocodezip
  • 158,664
  • 13
  • 220
  • 245
1
var klms = [{"url":"http:\/\/example.com\/points_in_a_kml_file.kml"}];

if(klms){
    $.each(klms, function(i, klms){
        $('#map').gmap3({
            action: 'addKmlLayer',
            url: klms.url,
            options:{
                suppressInfoWindows: true,
                preserveViewport:  false
            }
        })
    })
}

"points_in_a_kml_file.kml":

<?xml version="1.0" encoding="UTF-8"?>
<Document>
<Style id="style0">
    <IconStyle scale="0.181818">
        <Icon>
            <href>http://example.com/pin.png</href>
        </Icon>
    </IconStyle>
</Style>
<Folder>
    <name>pulau_weh_point</name>
    <Placemark>
        <name>Mama's</name>
        <description><![CDATA[Point's description]]></description>
        <Point>
            <coordinates>95.255227,5.875082,0.000000</coordinates>
        </Point>
        <styleUrl>#style0</styleUrl>
    </Placemark>
</Folder>
</Document>