I'm developing an app that tracks my location in real time, using FusedLocation API and Google Maps. I use a marker to show my current location.
My problem is that my location is always out of street, following parallel to the street while I move.
It does not seem an inaccuracy of GPS, but a discrepancy between the map and the location.
How can I fix this behavior?
Any help would be appreciated!
Try to use ACCESS_FINE_LOCATION instead of ACCESS_COARSE_LOCATION in the Android manifest permissions
https://developer.android.com/reference/android/Manifest.permission.html#ACCESS_FINE_LOCATION
Well gps data are not precise as they have a margin of error that allows them to be off the road. A solution to that is to snap the collected positions to the roads that are known to the api.
Here's a link to the docs that shows how to do that using the java api.
Note: For additional info, the page also gives an example for raw gps location and snapped locations superposed in an image right after the example code.
Related
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.
I want to Develop a project where it will work with custom map. I have a image in SVG format which is a campus image. I want to get the user current location and show the path of user selected location.
I can't understand where to start. How it worked. I know how to work with Google Map.
Very less tutorials are available in web. So I am unable to get sufficient help from Google.
Thanks in advance.
You cannot get user location using .svg image. Vector images can be use as a map marker, icon, symbol or image to a polyline.
If you want to get current location, use FusedLocationProviderApi. FusedLocationProviderApi provides improved location finding and power usage and is used by the "My Location" blue dot.
To show path selected location, use Google Maps Android API to expose intents that you can to launch Google Maps in display. It allows you to display map in a specified location and zoom level, show directions, search for a location and display them on a map. Directions can be returned in driving, walking or bicycling.
Here's a sample demo app which discuss how to get current location and show direction to selected location: https://github.com/googlemaps/android-samples/blob/master/ApiDemos/app/src/main/java/com/example/mapdemo/MyLocationDemoActivity.java
Start your poject by following steps listed in Official Google Documentation for Maps Android API. Here is the link : https://developers.google.com/maps/documentation/android-api/start#step_3_create_a_google_maps_project
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?
I am building a web app which contains a Google Maps link that can be opened by the native phone Maps app (iPhone/Android).
The link has the form:
http://maps.google.com/?q="+startCooLat+','+startCooLng;
and I have also tried the:
http://maps.google.com/?q=loc:"+startCooLat+'+'+startCooLng;
However in the native app the marker is positioned in the nearest street and not in the exact coordinates that I am giving. Is there a solution or another parameter to set so as to overcome this issue?
Instead of questioning (q=.....) google maps for the location, in which it returns what it thinks is the nearest human address to the location (somewhat annoying I think) you can pass a lat lng location where you want the center of the map to be. For example:
http://maps.google.co.uk/?ll=53.385517,-1.865315
Instead of:
http://maps.google.co.uk/?q=53.385517,-1.865315
I had this problem my self, and on my Android device at least this works. The second example simply puts the map on a road, the first is in the middle of the moors on the device in the maps app.
The full link from the comments:
http://maps.google.com/maps?ll=53.385517,-1.865315&q=loc:53.385517,-1.865315&t=m
This one seems to work at adding a marker for the standard maps app whilst still adding a marker.
After receiving a recent answer to an old Android Google Maps question I had, I have found another solution to this question, which I thought would be useful for others. Original Question - and credit to Captain Charmi for pointing me in the direction.
Instead of using the link above which will create a marker at the given location, trouble is, the maker is pretty meaningless, just the coordinates. If you use the following link, you can add either a title to the marker and show the coordinates:
http://maps.google.com/maps?q=53.385517,-1.865315+(My Random Location)
Or you can instead of adding a title, you can supply text to go inside the marker:
http://maps.google.com/maps?q=A pot of gold at the end of a rainbow#53.385517,-1.865315
As you can see, Google now drops the marker in the correct place due to being supplied the info for the marker. I hope this helps.
There is a Google map and on it marked objects. With GPS defining man's place on the map.
The aim is to set the phone automatically detects and plot a route to the nearest object. How can it be obtained?
I find this tutorial very helpful:
http://www.anddev.org/google_driving_directions_-_mapview_overlayed-t826.html