click - Google maps : How to open an InfoWindow for a Polygon by clicking on it? -


I have a simple question, but I could not find an answer in the Google Maps API documentation ...

I have a map with 13 polygons created by the API. Here's an example of one of these polygons:

  var zon_up_mantablank = new GPO (new GLTLNG (46.21270329318585, 6.134 9 9 3,11617), New GLTLNG (46.20538443787925, 6.136844716370282), New GLTLNG (46.20525043957647, 6.141375978638086), New G LatLng (46.20698751554006, 6.148050266912262), New GLatLng (46.21110286985207, 6.153203229026629), New GLatLng (46.21730757985668, 6.151718301267355), New GLatLng (46.22092122197341, 6.153676364285801), New GLatLng (46.22615123408969, 6.149844858907489), New GLatLng (46.22851200024137, 6.149876939987202), New GLatLng ( 46.22945159836 9 55, 6.142758190170017), New GLTLNG (46.217359 8463437, 6.141457132705133), New GLTLNG (46.21753573755057, 6.138058122426195), New GLTLNG (46.21270329318585, 6.1349090311617)], "# 6 B1F 43", 2, 0.9 , "# 92 C 87 F", 0.5);  

then:

  map.addOverlay (zone_up_montblanc);  

Polygons appear on my map, no problem. But now what I have to do is open the "Infundo" by clicking on each polygon (with a different material for each polygon).

Do anyone have any ideas or an example?

Thank you very much for your help!

I will describe the solution because I have not used it in a while, and any large Conflicts for uploading quantity code - here the code was not used for the editing feature. See API reference for details.

Then, start:

  1. You are adding a polygon using the map. AddOverlay (), then the map stores your polygons. / Li>
  2. Announce an event handler that clicks on the map. A GLatLng and overlays will be clicked on that event handler (in your case polygon). If the overlay is a polygon, you can test a simple type to decide.
  3. Use the event handler map.openInfoWindowHtml (), the GLatLng provided as a location, and you want to display HTML content

This is a simple is! You have to see how you attach event handlers, because I do not remember specially from top of my head. You need to look in the API:

  • Adding Event Handlers to the Map
  • Checking the Types of Overlays

You The way to call and the API should be able to get all the information on the page:

Good luck!


Comments