Google Maps API v3 - google.maps.geometry.poly.contains位置第一次
Google Maps API v3 - google.maps.geometry.poly.containsLocation not working the first time
我遇到了google.maps.geometry.poly.containsLocation(latLng,polygon)在页面加载时第一次不起作用的问题,但是在我开始触发事件后它又起作用了。
知道为什么会发生这种情况吗?
谢谢!
主要原因是第一次谷歌 API 没有正确加载并且您正在尝试使用
var rsul = google.maps.geometry.poly.containsLocation(new google.maps.LatLng(-12.043333, -77.028333), bermudaTriangle);
所以它显示"无法读取未定义的属性'poly'"
因此,我们需要使用超时来获取页面加载工作。
例:
setTimeout(function() {
var rsul = google.maps.geometry.poly.containsLocation(new google.maps.LatLng(-12.043333, -77.028333), bermudaTriangle);
console.log(rsul);
}, 1000);
所以它给出了适当的布尔值
相关文章:
- Three.js:geometry.addEventListener不是函数
- 为什么无法根据谷歌地图地理编码geometry.bounds找到位置,但可以通过MongoDB中的geometry.vi
- Angular 1.3+ui路由器+生成器ng poly嵌入嵌套(?)视图不起作用
- 使用 geometry.vertices 和 geometry.faces 从 .obj 文件创建网格
- Projections and OpenLayers.Geometry.Point in openlayers
- Google Maps API v3 - google.maps.geometry.poly.contains位置第一次
- 每当我更改“geometry.setDrawRange”属性时,同步就会停止
- 如何有效地将THREE.Geometry转换为ArrayBuffer、File或Blob
- geometry.faceVertexUvs[0][0][index] is not the same as geome
- 在Three.js中将一个Geometry转换为BufferGeometry是否会增加顶点的数量?
- TypeError: Object没有方法'split'分割结果错误[0].geometry.locat
- 谷歌地图apitparkin point-in-poly
- 将geomeyutils .merge()迁移到geometry.merge()
- poly .prototype.splice不像预期的那样工作
- poly趋向于在旋转时收缩
- Webstorm - Typescript, AngularJS and generator-ng-poly Gette
- google.maps.geometry.spherical error
- 转换ol.geo . geometry的布局
- 调用google.maps.geometry.spherical.computeDistanceOff是否会对我的API
- 我如何解决使用google.maps.geometry.spherical.computeOffset时“undefin