I am using a Geolocator to locate my current location.
I am trying to figure out the computation on how I can disable using a feature if you are outside the bounding box in the map.
I have this computation
if (x1 < x && x < x2 && y1< y && y < y2){
log('You are inside the bounding box');
} else {
log('You are outside the bounding box');
}
where;
x, y = my latitude, longitude
x1, y1 = northeast latitude, longitude
x2, y2 = southwest latitude, longitude
but this does not work well, can anyone provide me a much better solution for this?
CodePudding user response:
With this package you can create a custom polygon on map and detect where user is in reference to its lines. When user is outside the polygon you disable functionality.
Since you're using geolocator you can use more generic version of the package found here. And use it the same way with some kind of custom marker drawn on the map with your polygon.