Geo fence

344 views
Skip to first unread message

Samuel Ndhlovu

unread,
Oct 23, 2015, 4:57:04 PM10/23/15
to Leaflet
Has anybody had success using leaflet for geofence?if so please help me with examples if possible.I will be grateful.

ba...@redbird.fr

unread,
Oct 27, 2015, 2:53:21 AM10/27/15
to Leaflet
Hi, it's possible.
You can simply compare marker lat-long to rectangle bounding box for example.

samuel ndhlovu

unread,
Oct 27, 2015, 7:02:29 AM10/27/15
to leafl...@googlegroups.com
am a newbie developer,can you give me an example of how this can be done?

--

---
You received this message because you are subscribed to a topic in the Google Groups "Leaflet" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/leaflet-js/ehfPFyaDyHk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to leaflet-js+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

ba...@redbird.fr

unread,
Oct 28, 2015, 3:54:34 AM10/28/15
to Leaflet, s...@kokoliko.net
It should be something like that:

markerLatLng = myMarker.getLatLng();
rectSouthWest = myRect.getBounds().getSouthWest();
rectNorthEast = myRect.getBounds().getNorthEast();

if(  (markerLatLng.lat > rectSouthWest.lat && markerLatLng.lng > rectSouthWest.lng) && (markerLatLng.lat < rectNorthEast.lat && markerLatLng.lng< rectNorthEast.lng) ){
  alert
("you're in");
}else{
  alert
("you're out");
}

I'm pretty sure that you can find solutions in a plugin like this one.

Some doc to help you:

Good luck!

Arnie Shore

unread,
Oct 28, 2015, 4:02:30 AM10/28/15
to leafl...@googlegroups.com
Let me note that if your fence is rectangular, then this can work.  But if it's more complex, like a geographic boundary, then you'll need some sort of point-in-polygon logic.

On Fri, Oct 23, 2015 at 4:57 PM, Samuel Ndhlovu <ndhlov...@gmail.com> wrote:
Has anybody had success using leaflet for geofence?if so please help me with examples if possible.I will be grateful.

--

---
You received this message because you are subscribed to the Google Groups "Leaflet" group.
To unsubscribe from this group and stop receiving emails from it, send an email to leaflet-js+...@googlegroups.com.

ba...@redbird.fr

unread,
Oct 28, 2015, 4:26:45 AM10/28/15
to Leaflet

Yes, this method only work for rectangle fence. With an other kind of polygon it could be wrong :



In this sample, the point is in the bounding box (yellow) but not in the polygon (red).

Message has been deleted

Matt Travis

unread,
Oct 28, 2015, 7:29:34 AM10/28/15
to Leaflet

Steve Mitchell

unread,
Nov 29, 2015, 4:44:51 PM11/29/15
to Leaflet
Reply all
Reply to author
Forward
0 new messages