How to update latitude/longitude in Android on google maps? - android

I am developing an indoor location application where the latitude/longitude will be updated from gathered sensor data. I cannot find any API that assists with simply updating the latitude/longitude on a map as that is literally the only thing I want to do. I do not want to use GPS data as the intent of the application is for indoor locations where GPS signal is heavily challenged i.e. under ground parking. Did I maybe miss something in the google maps API that someone can point me too? I will be calculating the new latitude/longitude using old lat/lon data and the sensor data (accelerometer for example).
So long story short, I want to update the marker on the map using sensor data only and I cannot find a library function in the API that allows me to update latitude/longitude on the map. Is there anything that can do that based on the new latitude/longitude I calculate?

You should save a reference (1) of the marker that you first create, and then update (2) his location.
1)
Marker marker = mMap.addMarker(new MarkerOptions().position(firstLatLng));
2)
marker.setPosition(newLatLng);

Actually, if you want to know more about updating all map features take a glance at google map API
But, if you are running out of time and want a quick fix to your lattitude and longitude updates every time then have a look at this receiving location updates

Related

I want to retrieve the latitude and longitude of a location shown in google map route between two locations

I have lat and long of some locations in JSON. I want to spot whether these locations are present in a route shown by google maps.
Here are the steps I'd consider to achieve the effect you want:
Query for a DirectionResponse https://developers.google.com/maps/documentation/directions/intro#DirectionsResponses
For each polyline of each step of each leg, test whether your locations are close to the line. For simplicity you can also use the overview_polyline. Unfortunately this is not simple to do out-of-the-box using the Maps API alone. Check this thread for inspiration on a manual implementation. Find a point in a polyline which is closest to a latlng
Alternatively, convert the polylines to GeoJSON, and process using a spatial library such as JSTS or Turf. E.g. the latter provides a pointOnLine function.

Android gps coordinates location updates

I want to develop an app that receive from the server coordinates every 10 seconds and update the location on the map. How to do it?
On how to obtain the GPS coordinates look here:
https://developer.android.com/training/location/receive-location-updates.html
You can set the update interval to 10 seconds in the LocationRequest object.
For integrating a map in your app and setting markers on it you can look here:
https://developers.google.com/maps/documentation/android-api/start (for google maps)
or use some alternative provider for maps data like OpenStreetMap (see https://github.com/osmdroid/osmdroid).
Edit: Maybe you should start with a tutorial like this one: http://code.tutsplus.com/tutorials/getting-started-with-google-maps-for-android-basics--cms-24635

How to get latitude and longitude of current location using google map api but without displaying the maps?

I want to get only the latitude and longitude of my current location using google maps. But I dont want to display the map. Is it possible to do so? And how can I use only Internet without Gps to get my current location?
You need to get the location using a LocationManager, Google Maps actually utilizes similar functionality to get the location before drawing it (and the map) for you. You may certainly only use your network provider for GPS locations, you should look into differences between FINE and COARSE locations (and their permissions). I would start posting links, but there are tons. Just start googling for LocationManager and Network GPS on Android. Just for fun though, here is the first link I found (seems to be pretty solid).
http://www.androidhive.info/2012/07/android-gps-location-manager-tutorial/

Trace the location only on Road in Google maps V2 android

I want to show the current location of the user only on road(not beside of the road) while moving. I have used the LocationManager to get the current location. But sometimes I am getting the location beside the road, with this, the location point on map is showing beside the road. Actually, I have to show his location on Road(if he is beside the road) only. I searched lot for this but didn't get any idea.
Example: How I am getting the current locations on map.
m
A---n-------B
here, A is start point
B is end point
n is on road(current location for sometime)
m is beside road(current location)
But I would need the m also should be on road.
Please help me on this..
The google directions service will calculate from nearest road so calculate directions from current location to current location - returned starting location will be on a road.
But what if user genuinely is off-road in a shopping mall carpark for instance?
For that you need to use road API which will give you the path upon the road otherwise you will not get the accurate path.
Snap to Roads
The Google Maps Roads API takes up to 100 GPS points collected along a route, and returns a similar set of data, with the points snapped to the most likely roads the vehicle was traveling along. Optionally, you can request that the points be interpolated, resulting in a path that smoothly follows the geometry of the road.
Check Details Here
You need to call like this
https://roads.googleapis.com/v1/snapToRoads?path=-35.27801,149.12958|-35.28032,149.12907|-35.28099,149.12929|-35.28144,149.12984|-35.28194,149.13003|-35.28282,149.12956|-35.28302,149.12881|-35.28473,149.12836&interpolate=true&key=YOUR_API_KEY

Marking places in android app not on the 'Google Places' database

I want to add markers on map for my android app. I do know how to do it (overlay items). My question is: Since I am manually putting markers on points(on the map) whose lat/long's I already know, I want to know if there is any way to get the exact latitude and longitude of a place on google map? Right now I am asking my people to go to the particular places and use this ( http://bit.ly/K4fOcy ) app to determine the lat/long of that place and send it to me via e-mail. I use these lat/long values to put markers on my map in the app. But the latitudes and longitudes i get are not accurate. they have around 300-2500m error (on real scale).
Or shall I use the Google Places API? How does it work? What about the places which are not in the Google Places database? How do I exactly mark them on the map? I would be very grateful if someone points me in the right direction.
Thanks
If you are working with establishments that aren't represented in the Google Places API and want to be able to pull coordinates directly from http://maps.google.com/, you simply:
Find the location of interest on the map, using an address or just knowledge of the area
Right-click on the map and select What's here? from the context pop-up menu
The Lat-Lng coordinates will be automatically populated in the search input box and usually, the address will also be displayed in the dynamic side-panel (and very often a Street-View photo).
If you are looking for a way to query for the coordinates, you can use the Geocoderdev-guide service to turn addresses into coordinates.
Have you looked at the geocoding API for google maps? It allows you to pass in an address, and returns a Latitude/Longitude pair in response, there is an accuracy value returned with each response to let you know how close the geocoder was able to resolve the location. https://developers.google.com/maps/documentation/geocoding/

Categories

Resources