How to use containsLocation in Google maps geometry library.

前端 未结 2 1971
梦如初夏
梦如初夏 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:09

    i had the same problem ([object Object]), I could solve that creating the polygon variable like that: draw = new google.maps.Polygon({paths:polyOptions});

    Then the problem disappeared.

    0 讨论(0)
  • 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");
    }
    
    0 讨论(0)
提交回复
热议问题