Search code examples
google-mapsgoogle-maps-api-3kmlpolygons

Is it possible to add a Polygon layer to a google map v3 without using fusion tables


The question is pretty descriptive.

I am working on a website that provides locations for filming.

All the data in the site is currently stored in a MySQL database including geocode data for google maps.

I need to show polygon areas for the different london boroughs that has locations.

I have all the data as kml files, idealy i would like to store this in the MySQL database.

I have had success using fusion tables to display this data, but it seems silly to me to have to have this data duplicated on google just to use a fusion map layer, can i simply use a kml layer to render this data rather than having to create a fusion table and rendering it from that?

If so, is there a resource someone could point me to for more information?

UPDATE: Thank you for the responses so far, i thought i would update the question with a little more info .

I eventually want to have all the areas displayed at the same time on my map and then when an area is clicked on ideally it would take you to another page on the website showing locations for that specific area.

I had initially tried using KML layers but i was getting errors saying my KML was invalid. The KML was initially stored in a field in my database table, i think probably the errors were due to me not understanding exactly how google read in the KML data.

Using polygons would be far simpler to implement as i can get this data via JSON and then render the polygons from that.

I know now its not possible to have info windows with polygons, but i would just prefer to jump directly to another website page with info for that particular area using a click handler rather than show an info window. Alternatively as suggested showing a tool-tip with a brief description of the area and a link to the page would be better, how the tooltip itself, is it possible to render on top the map?

I am slightly worried that I will reach the layer limit for the KML. Is it possible to have multiple polygons rendered with KML on one layer, or do i need a separate layer for each clickable area?


Solution

  • The Google Maps API provides a pretty straightforward method to draw polygons.

    Basic Example:

    var polygon = new google.maps.Polygon({
      map: your_google_map_instance,
      paths: array_of_latlng_points,
      fillColor: "#336699",
      fillOpacity: .5,
    })
    

    EDIT: For this approach, you would need to parse your KML files (sorry, must've missed that when I first read it). You can import the KML files to a KML layer