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
Related
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
Sorry if this question is obvious, I haven´t found a clear answer in other posts.
I am creating an Android app and I am planning to use the Google API to get a more accurate location. My question is about the request limit of the API(2500 request per day if you don´t pay): I guess that every time I call getLastLocation() counts as a request, but in my app I want to update the location periodically using LocationRequest methods like setInterval()
Thank you in advance.
taking geo-location and plotting it on Map are two different things.
To get geo-location there in no such limit as of now! From Android version O, there will be such limit for background location limit refer this URL
to Plot the coordinates on map these is such limit as mentioned here
so your can take any amount of location data,but plotting it on Map is limited i.e 2500/day.
I want to make a android app using google maps.In this app I want to share my location to my friend like a request, Once he accepted my request he will get the route map to my location (previously I shared) and also I want to see his moving path towards my location. Can any one please suggest me how is possible to sharing locations.
I think the best way to control that sharing is using socket.IO
on the device you catch your position then emit your position to the server and on the server side you emit to other devices.
Hope helped you
For sharing locations and showing it on map, you need to do it in following steps
Read your location using android APIs.
Once he accepts your request, read his location and share it to your profile through some API to server & keep on updating location on every changed distance delta or at some time interval and share that too.
Now you have co ordinates of both locations. Use them to fill data to Google Maps API and load map in one of your activity. Whenever you will receive updated location of your friend from your server, update the map and draw path between them using google maps api.
For showing map to your location # your friends side, same thing needs to be done. If your location will also change then you will have to provide your updated location to server timely as mentioned in step 2
What if you send a geo: link to your friend? Like geo:62.0,-7.0 ? That should give the receiver a choice between all his geo-capable apps. Google Maps, OsmAnd, maybe some weather service...
I am pretty much a novice at Android development, so please feel free to describe in very simple terms any advice you may give in response to my query.
I would like my application to start by displaying an Activity zoomed out to an extent that shows both my current location and that of a marker that I have placed on a map some distance from me.
I have successfully placed and displayed the remote marker the on the map and have found this class: LatLngBounds.Builder, which allows me to determine the bounds of all locations I am interested in, by supplying it the locations via its include method.
I obviously know the LatLng of my remote marker, but rather than going through the rigmarole of getting my current location using Google Play services and the location services API was wondering if, as my location has already been determined and is being displayed as the standard Google small blue circle, by virtue of me having set map.setMyLocationEnabled(true), whether my code has access to this ‘marker’. If it has, and I somehow know its ID, then could I not simply determine my location from [currentLocationBlueCircleMarker].getPosition()?
Thank you
There used to be a way to get a Location from a GoogleMap object, but it has been deprecated:
com.google.android.gms.maps.GoogleMap.OnMyLocationChangeListener
This interface is deprecated. use
com.google.android.gms.location.FusedLocationProviderApi instead.
FusedLocationProviderApi provides improved location finding and power
usage and is used by the "My Location" blue dot. See the
MyLocationDemoActivity in the sample applications folder for example
example code, or the Location Developer Guide.
So, you will need to use other means to get the current Location, though it's quite simple to get the current location using the FusedLocationProviderApi from Google Play Services.
For a complete example (targeting api-23 and up) see here: https://stackoverflow.com/a/34582595/4409409
For a complete example (targeting api-22 and down) see here:
https://stackoverflow.com/a/30255219/4409409
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/