How to use containsLocation in Google maps geometry library.

前端 未结 2 1975
梦如初夏
梦如初夏 2020-12-11 07:43

I am trying to use the containsLocation from the Google geometry library, but can\'t get it to work...

var point = new google.maps.LatLng(51.331         


        
2条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-11 08:19

    Oke, stupid me

    I was wrong using all the coords as an array, I had to use the created polygon object.

    var polyOptions = {
     ...
    }
    
    draw = new google.maps.Polygon(polyOptions);
    draw.setMap(map);
    
    if(google.maps.geometry.poly.containsLocation(point, draw) == true) {
     alert("yes");
    }
    

提交回复
热议问题