You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Creating a geofencevarnewGeofence={}newGeofence.name="New geofence"newGeofence.latitude=29.763638newGeofence.longitude=-95.461873newGeofence.radius=250newGeofence.tags="geofence-tag"geofence.create(newGeofence.tags,newGeofence.name,newGeofence.latitude,newGeofence.longitude,newGeofence.radius)
Retrieving by Tag
// Retrieving a geofence by tagsvargeofencesFoundByTag=geofence.tagged("geofence-tag")if(geofencesFoundByTag>0){varfirstGeofence=geofencesFoundByTag[0]if(firstGeofence){console.log("Found by 'geofence-tag' geofence name: "+firstGeofence.name)console.log("Found by 'geofence-tag' geofence latitude: "+firstGeofence.latitude)console.log("Found by 'geofence-tag' geofence longitude: "+firstGeofence.longitude)console.log("Found by 'geofence-tag' geofence radius: "+firstGeofence.radius)console.log("Found by 'geofence-tag' geofence tags: "+firstGeofence.tags)}}
Retrieving by ID
// Retrieving a geofence by IDvargeofenceID=1500vargeofenceFoundbyID=geofence.find(geofenceID)if(geofenceFoundbyID){console.log("Found by 'geofence-tag' geofence name: "+geofenceFoundbyID.name)console.log("Found by 'geofence-tag' geofence latitude: "+geofenceFoundbyID.latitude)console.log("Found by 'geofence-tag' geofence longitude: "+geofenceFoundbyID.longitude)console.log("Found by 'geofence-tag' geofence radius: "+geofenceFoundbyID.radius)console.log("Found by 'geofence-tag' geofence tags: "+geofenceFoundbyID.tags)}
Updating
// Updating a geofencevargeofenceID=1500varupdatedGeofence={}updatedGeofence.name="Updated geofence"updatedGeofence.latitude=23.54590updatedGeofence.longitude=-98.461873updatedGeofence.radius=1000updatedGeofenceTags="geofence-tag,geofence2-tag"geofence.update(geofenceID,JSON.stringify(updatedGeofence),updatedGeofenceTags)
Deleting
// Deleting a geofencevargeofenceID=1500geofence.destroy(geofenceID)