javascript - 如何在反应中检查标记位于多个多边形中
问题描述
这段代码只需要一个多边形我想要一些可以带多个多边形的东西来检查 lat lng 是否位于其中一个!有什么解决办法吗?
componentDidMount() {
const polygon = [
{ lat: 3.1336599385978805, lng: 101.31866455078125 },
{ lat: 3.3091633559540123, lng: 101.66198730468757 },
{ lat: 3.091150714460597, lng: 101.92977905273438 },
{ lat: 3.1336599385978805, lng: 101.31866455078125 } // last point has to be same as first point
];
let point = {
lat: 2.951269758090068,
lng: 101.964111328125
};
GeoFencing.containsLocation(point, polygon)
.then(() => console.log('point is within polygon'))
.catch(() => console.log('point is NOT within polygon'))
}
解决方案
推荐阅读
- ruby-on-rails - Rails 通过与 has_many 和 belongs_to 的关系
- python - 使用 pyinstaller 编译可执行文件时发现缺少 dill
- css - tailwin css 无法正确上传
- node.js - 当目标具有基本 url (NodeJs http-express-proxy) 时,Url 转发不起作用
- php - 无法从 WooCommerce 结帐中保存自定义复选框值
- flutter - 如何让用户使用 JWT 登录 Flutter 应用程序?
- python - 生成 Google 搜索 url 的 Python 程序
- excel - 选择除标题以外的所有使用范围
- java - 传递空值时区分名称相同但参数列表不同的两个方法
- javascript - 仅匹配空格而不匹配选项卡、回车或 Javascript 中的谎言提要的正则表达式