Skip to content
Advertisement

use multiple location geofencing

I used this code

(https://www.youtube.com/watch?v=nmAtMqljH9M&list=PLdHg5T0SNpN3GBUmpGqjiKGMcBaRT2A-m&index=9&ab_channel=yoursTRULY)

(https://github.com/trulymittal/Geofencing)

That code makes geofence by click and uses just one geofencing.

But I wanna make geofence one more fixed markers when it start, and use one more geofencing.

So I revised this code(MapsActivity.java) by

JavaScript

As a result, when start the app, four markers and Circles(I added fout latLng) are added on the map!

But only the last latLng works geofence function (LatLng(38.462743, 123.910317), such as alarm when enter the place),

the others doesn’t work geofence function.

I want to make the others location works geofencing function well lol

Plz. help me 🙁

I need a hint

Advertisement

Answer

You’re creating a new Geofencing Request for each LatLng coordinate. Instead, you should create a single Geofencing Request containing a list of all Geofences you want to monitor:

Create a function to build your Geofencing Request:

JavaScript

You should change addGeofence() to look something like this:

JavaScript

Finally, inside of your onMapReady():

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement