Dynamic geofence and google maps Android app - android

I am asking advice on the best way to create a geofence application for android application using google maps.
I have looked at the sample code given on the android documentation but I am not sure if this satisfys what I wish to do. Basically I wish to show the user location and a radius and alert if the user goes outside this radius. The size of the radius is dynamic and can be dependant upon the time of day.
Could anyone give me any good starting points on what I should be looking at please? I know this is a general question but I am seeking advice on the best way to achieve this not for someone to supply code and give me it.
Thank you

User location can be obtained using GPS and as you said radius is dynamic and is dependent on time, so radius can be figured out from time. Now you have user location and radius. Now, you can calculate distance of user location from center of circular geofence and then compare it with radius.
Distance calculation between two points over map can be done using API like "distanceTo" available in developer website. http://developer.android.com/reference/android/location/Location.html
If radius is bigger than distance, user is inside the geofence and if radius is smaller than calculated distance, then user is outside of dynamic geofence.
For more info regarding implementation- visit
http://developer.android.com/training/location/geofencing.html

Related

Geofencing procedure

How does geofencing works? I mean I just need two GPS coordinates (user's and target's GPS coordinates) and radius, then find distance between of them and if distance is less than or equal to radius then person is in geofence . Or there is more?
That's pretty much it. There's probably some smoothing algorithms (to protect against bad readings causing a jump in a person's location),but its pretty much a distance check between two coordinates.
The above solution work fine if we have a circular geofence, But if we have a geofence in a polygon shape, then we have to check if the user's location is within the boundry of the polygon.
There are many ways to do so
1. Google apis (if we are looking for android development).
2. Here map ( if we are going to expose rest apis, it is paid service).
3. Openmap provide library which can be used to create rest back end points . (free)

How to track route of user between two locations?

I have two Addresses let say Location A and Location B. And I have series of location between those Location A and Location B. I get those series of locations via Fused location API. and saved them on the server. Now following are my requirements :
What I want:
I want to calculate the distance between the Location A and Location B. Right Now I am using a code (link of post here) but it is giving me displacement.
Problems and Confusions:
I know about Google Distance matrix API and Google Directions api, but I really do not want to work on these apis as these are costly to me. But if I use them, I really did not understand that how API will know the route user selected. I mean it is possible that User has adopted the long way towards his destination. And I think google Direction and Distance API are returning the distance between Location A and Loation B using shortest route.
I really do not want to use the API, but if there is non other
possible way to do that then How could I get that ? and what is best
for me. Please suggest me the solution.
I think you have just idea of your logic but you do not know what it is called. Though it is too late but I am posting for your information or in case of if someone later on visit here.
To draw lines between two points on Map,Use Polylines and polygons. To read further I will refer you to this google page, It has a breif introduction and also a source code. And it is even really easy to implement. Here you go.

Google maps api v2 how to find the nearest location

I am using Google maps api v2 in android. I have created xml parser for the bus stop. Bus stops are displayed using markers. I need to find the user's current location and find the nearest location (bus stop), best automatically (for example in a radius of 0.5 kilometer).
I tried to find a tutorial, but unfortunately I failed it.
Thank you for your help.
There is the distanceTo() method of Location class that gets the distance between 2 locations, in a straight line. You can find an example on how to use this here: How to get straight distance between two location in android?
But, if you don't want the straight line distance, rather the Travel distance, I'd recommend you take a look at this question and answer: Get the distance between two locations in android?

Alert when current location is near marker android map

I am building an app for android that uses google map. its like a navigation app that updates the location on screen while in motion. I have placed multiple markers on the map and for each marker there is a radius of 125. When the current location intersects with the marker radius I get a warning message. This is done by looping through all markers and check if the current location intersect with the radius of any of the markers at the OnLocationChangedMethod() . it works well if you have couple of markers but I have more than 30 markers. By the time it takes to loop through all markers and report if there is an intersection , current location would have passed the marker. so it takes longer time and its not very efficient.
I hope someone can help for a better approach on how to do that. I have read couple of solutions that suggest taking the map bounds and find the visible marker. but this also iterate through all marker and it would take the same time as my solution.
I would appreciate if anyone could help.
Thanks,
Abdullah
This sounds like you would be better suited for Geofencing because it is basically what you are trying to do. No need for all these different services and such when there is something already built in
Use two services. One to get the current location and another to calculate the distances.

Do not want to show the exact location with Google Map in my Android app

This might be a bit off-topic. But I have been searching a lot for this and could not find anything.
I am developing an app, which would show to the user the near-by activities happening based on his current location. The client wants to show all the near-by activities in a map like view. But the issue is that he does not want to show the exact locations of the activities, due to privacy issues. Just a rough view of the things happening around in a map would be ideal.
Is it possible to prevent showing the exact details using a google map. Is there any alternate visual representation for this scenario.
Kindly help.
You may send to Android application a LatLng that is randomized and accuracy value in meters. This way you can represent an activity using Circle class with optional Marker in the center, so you can get info windows easily.

Categories

Resources