Question

J'ai une carte ici

Comment puis-je, en utilisant l'API Google Maps, détecter si oui ou non une coordonnée donnée est dans ce polygone? Est-ce possible?

Merci à l'avance.

Était-ce utile?

La solution

Oui, il est possible. Voir cette fonction: http://github.com/tparkin/Google-Maps-Point -en-Polygon

Autres conseils

Google fournit déjà un

  var bermudaTriangle = new google.maps.Polygon({
    paths: [
      new google.maps.LatLng(25.774, -80.190),
      new google.maps.LatLng(18.466, -66.118),
      new google.maps.LatLng(32.321, -64.757)
    ]
  });

  google.maps.event.addListener(map, 'click', function(event) {
    console.log(google.maps.geometry.poly.containsLocation(event.latLng, bermudaTriangle));
  });

https://developers.google.com/maps/documentation/javascript/ géométrie # containsLocation

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top