I am using the new API V2, but that's probably not important since I am newbie for maps anyway:)
I have very simple need. I want to show my location and one target marker and all is working. It's just that the my location determination is not predictable, can get minutes or so to get the blue circle.
What I thought is to manually use the LocationManager to retreive in background the coarse or fine location and pass that value to the Mapactivity. Since normally the map activity will not start immediatelly it would work nice. Then I could also save to databse the last location and pass that in the case the map activity starts before the LocationManager get the real location.
I am looking at the api's but could not find a function that would display imemdiatelly the blue circle at given LatLong. Is this function available?
If this function is not available the only workaround that I could find is to override onlocationchanged to retrieve the new location and save the last, and to display the marker on last known mylocation (that would hide automatically itself on first locationchanged event).
But it would be easier, and also pretier, if I could simply pass initial mylocaltion coordiantes?
Thanks for any idea
I am looking at the api's but could not find a function that would display imemdiatelly the blue circle at given LatLong. Is this function available?
Use setLocationSource() to provide a LocationSource to the GoogleMap. Once your LocationSource is called with activate(), you will be handed a listener object, to which you can pass Location objects for the readings you get from a location provider.
Related
All the examples I've seen for adding a marker to the map show the marker being added in the "onMapReady" callback or the "onMapClick" callback. I have an app that periodically finds the user's latitude and longitude and I want to add a marker to the map when the lat and lng updates. This happens outside of the previously mentioned callbacks. How would I do that? I need access to the Style object of the map but it's only accesible inside the callbacks.
The reason these callbacks (in particular onMapReady) are used in all the examples is to ensure that the mapboxMap objects's style has been loaded by the time you attempt to modify it - if it isn't there is the potential for some asynchronous weirdness as the map renders.
I would recommend you still include the logic for adding the periodic lat/lon coordinates as markers within the onMapReady callback.
⚠️ Disclaimer: I currently work for Mapbox ⚠️
I'm currently doing some research about a very small app I wanna try building.
The core concept will consist of moving randomly spawned GPS Location objects closer to the Location of the user as time passes by.
I have been looking through the Location API and as I understand all I need to do is updating the altitude and latitude of the spawned Location object to change its position. Now I'm curious what the best method is to: "Move a Location closer to another Location by 10 meter".
Is there already some existing API that achieves that goal like this hypothetical function:
Location newLocation = Location.moveTo(Location locationFrom, Location locationTo, int distance);
or do I have to write my custom algorithm?
What would be an efficient approach in this case? Any inputs are highly appreciated!
If the problem would exist in a Cartesian coordinate system I would just substract the user Location from the spawned Location to get the direction I need to move too and then add parts of the new vector to the spawned Location to get it closer.
How can this get solved with Location's ?
EDIT: I sumbled upon this thread: Move a LatLng 5 meters towards another LatLng
I guess using SphericalUtil.java is the way to do it.
I have a google map fragment set up in my activity and an onLocationChanged() and getLastKnownLocation running in coherence with it.
However when i run my application , my map points to the right city and everything but the location is off from the original location by about a few km or so .
To understand why this was happening ,
I tried the following
1. Used the Button to reset the location with the location update
2. Logged my Location
3. Waited for the interval to reset my location
In all these cases my actual location was the end result either in the map or in the log with no significance of the fake location anywhere in the log .
So i set up a camera changed listener to understand the new location and acquire the coordinates but the coordinates it gave had a much higher precision than the original coordinates and im guessing somehow the problem arises when the coordinates are parametrised into the latlng class.
Ex:
Normal:
xx.xxxxxxx xx.xxxxxxx
Camera Changed Listener coordinates:
xx.xxxxxxxxxxxxxxx xx.xxxxxxxxxxxxxxx
Can anyone explain this?
In my application, i used googlemap. In that, in a particular location i placed one object(Bike or Car). Then i moved to some other location. Now, based on my current location i need to show one arrow(campus) , in which direction i placed my Car or Bike.
For this, i saved my object location values in SharedPreferences , and i get Current location values(Lat and Lang). But, i dont know how to show arrow in that particular direction.
Finally, i have both (my object and my current location) latitude and longitude values. But, i am unable to show arrow from my current location to my object.
So, please guide how to do this.
Look in to this
http://googlemaps.github.io/android-maps-utils/
its a utility library that people put together.
Look into https://github.com/googlemaps/android-maps-utils/tree/master/library/src/com/google/maps/android
There is a SphericalUtil.java which has a method called computeHeading that might help.
Beside all, there are lots of helpful methods in this library for use.
Hope it helps
This might be a noob question for some of you. I want to create an action for android application where if someone is close to some certain location using geopoint and i want to verify this using mylocation to create an action which will location aware. Any idea ??
You could hold the location you want to reach in a Location object,
and then every time location gets update from the GPS, or every few seconds or so, check ths distance to it. and if it's smaller than a given value, you're there.
check this out
http://advback.com/android/finding-distance-between-two-points-with-google-maps-android/
EDIT:
Since you mentioned you want to use GeoPoint, here's a quick explanation on how to convert between the two:
Convert GeoPoint to Location