Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
[sdk.geofenceManager removeGeofenceListener:geofenceListener];

EDITING GEOFENCES

For a circular geofence it’s possible to change its center and radius using center and radius properites respectively.

To modify a polygonal geofence use coordinates property.

To update a geofence when its corresponding editable NMGeoObject is modified (for example, when a user drags a NMGeoCircle to a different location), use NMGeoObjectListener onGeoObjectChanged: method:

Code Block
- (void)onGeoObjectChanged:(NSUInteger)geoObjectID {
        
    NMGeoObject *geoObject = [self geoObjectForId:geoObjectID fromArray:geoObjects];
    
    NMGeofence *geofence = [self geoGeofenceForGeoObject:geoObject fromArray:geofences];
    
    if ([geoObject isKindOfClass:[NMGeoCircle class]] && [geofence isKindOfClass:[NMGeofenceCircular class]]) {
            
            NMGeoCircle *circle = (NMGeoCircle *)geoObject;
            NMGeofenceCircular *geofenceCircular = (NMGeofenceCircular *)geofence;
            geofenceCircular.radius = circle.radius;
            geofenceCircular.center = circle.center;

      } else if ([geoObject isKindOfClass:[NMGeoPolygon class]] && [geofence isKindOfClass:[NMGeofencePolygonal class]]) {
          
            NMGeoPolygon *polygon = (NMGeoPolygon *)geoObject;
            NMGeofencePolygonal *geofencePolygonal = (NMGeofencePolygonal *)geofence;
            geofencePolygonal.coordinates = [polygon.vertices copy];
      }
}