知道标记是否包含在离子中的多边形内

问题描述 投票:0回答:1

我有一个疑问,除了寻找解决我的问题的代码。是否可以从本地cordova-plugin-googlemaps执行此类计算?或者我应该从谷歌地图导入javascript脚本? google地图功能会在原生谷歌地图插件上运行吗?非常感谢你

google-maps ionic-framework ionic2 ionic3
1个回答
1
投票

使用poly.containsLocation() https://github.com/ionic-team/ionic-native-google-maps/tree/master/documents/poly#containslocationlocation-path

marker.on("position_changed").subscribe((params: any[]) => {
  let latLng: ILatLng = params[0];  // or marker.getPosition();

  let contain: boolean = Poly.containsLocation(position, POLYGON_POINTS);
  marker.setIcon(contain ? "blue" : "red");
});

https://github.com/mapsplugin/cordova-plugin-googlemaps-doc/blob/master/v2.3.0/class/utilities/geometry/poly/containsLocation/README.md

© www.soinside.com 2019 - 2024. All rights reserved.