地理位置和地理围栏工作正常(出现在console.log中)。我试图在进入地理围栏A时触发事件A,并在进入地理围栏B时触发事件B(而不是console.log)。
//geofence A
const polygon = [
{ latitude: 37.717789, longitude: -122.482091 },
{ latitude: 37.718197, longitude: -122.475742 },
{ latitude: 37.715413, longitude: -122.475399 },
{ latitude: 37.715481, longitude: -122.482263 },
{ latitude: 37.717789, longitude: -122.482091 }
]
//geofence B
const polygon = [
{ latitude: 37.718774, longitude: -122.470557 },
{ latitude: 37.718876, longitude: -122.464252 },
{ latitude: 37.716431, longitude: -122.464209 },
{ latitude: 37.716567, longitude: -122.469142 },
{ latitude: 37.718774, longitude: -122.470557 }
]
let point = {
lat: 2.951269758090068,
lng: 101.964111328125
}
GeoFencing.containsLocation(point, polygon)
.then(() => console.log('point is within polygon')) //event A or B instead
.catch(() => console.log('point is NOT within polygon'))
}