Android Question notification when approaching to a place

Mr Blue Sky

Active Member
Licensed User
Longtime User
I want a notification when approaching my marker approach to a place the marker radius is 250 meter

Untitled-1.jpg


The place are actually stored to place.kml and i use already Google maps v2 - GoogleMapsExtras in MapFragment and creating one monitoring geofences

if a good soul can help me !

it's been a week that I am on this problem that I ask questions without having an answer


Sub MapFragment1_Ready
Log("MapFragment1_Ready")
gmap=MapFragment1.GetMap
If gmap.IsInitialized Then

Dim m1 As Marker
m1=gmap.AddMarker(gmap.MyLocation.latitude, gmap.MyLocation.longitude, "toto")
m1.Snippet = "this is toto"

Dim cp As CameraPosition
cp.Initialize(gmap.MyLocation.latitude,gmap.MyLocation.longitude, 18)
gmap.AnimateCamera(cp)

Dim KMLLayer1 As KMLLayer
KMLLayer1.Initialize(gmap, File.OpenInput(File.DirAssets, "place.kml"))
KMLLayer1.AddLayerToMap

If KMLLayer1.HasContainers Then
Dim Containers As List=KMLLayer1.GetContainers
End If

If KMLLayer1.HasPlacemarks Then
Dim Placemarks As List=KMLLayer1.GetPlacemarks
End If

Else
Log("Error initializing GoogleMap")
ToastMessageShow("Error initializing GoogleMap", False)
End If
End Sub

Sub AddGeofence
Dim geo As Geofence
geo.Initialize
geo.Id = "DETECT"
geo.Center.Initialize2(gmap.MyLocation.latitude,gmap.MyLocation.longitude)
geo.RadiusMeters = 100
geo.ExpirationMs = DateTime.TicksPerDay 'expire after one day
CallSubDelayed3(GeofenceService, "AddGeofence", Me, geo)
Wait For Geofence_Added (Success As Boolean)
Log("Geofence added: " & Success)
End Sub
 
Last edited:

Mr Blue Sky

Active Member
Licensed User
Longtime User
I think I'm wrong it's not one monitoring geofences that i have to use to do what I want. geofences defines a perimeter of detection whereas I want to detect the marker KML close to me. I think it Google Places API for Android
 
Last edited:
Upvote 0

Mr Blue Sky

Active Member
Licensed User
Longtime User
It not Google Places API too, I do not really know how others do this I spent hours on the internet looking for a solution I can not find an example or tutorial. it's surely a big secret lol
 
Upvote 0

Mr Blue Sky

Active Member
Licensed User
Longtime User
exemple with excel file
2.18078, 47.08134, POI1
2.62847, 47.20464, POI2
2.58453, 46.99898, POI3
etc...

B4X:
Sub AddGeofence
    Dim workbook1 As ReadableWorkbook
    Dim moviesSheet As ReadableSheet
    workbook1.Initialize(File.DirAssets, "poi.xls")
    moviesSheet = workbook1.GetSheet(0)

    Dim geo As Geofence
    geo.Initialize

    For row = 0 To moviesSheet.RowsCount - 1
          geo.Id = moviesSheet.GetCellValue(2, row)
          geo.Center.Initialize2(moviesSheet.GetCellValue(1, row), moviesSheet.GetCellValue(0, row))
          geo.RadiusMeters = 150
          geo.ExpirationMs = DateTime.TicksPerDay
         CallSubDelayed3(GeofenceService, "AddGeofence", Me, geo)
         Wait For Geofence_Added (Success As Boolean)
         Log("Geofence added: " & Success)
    Next
End Sub

maybe not professional but it is my solution with the information that I have. the problem is that Geofences Monitoring detects the position in a radius of 150m and not in the direction of the road and a limit of 100 per device user. without support not easy to know what kind of APIs or libraries used. no one is communicating any help on this noticed

also it works upside down the marker detects me while those who want to detect the marker
 

Attachments

  • notification when approaching to a place.zip
    15.3 KB · Views: 329
Last edited:
Upvote 0

Mr Blue Sky

Active Member
Licensed User
Longtime User
Last edited:
Upvote 0
Top