I'm making a new private android app to take a picture, get your current location in WGS84, and at last send it all in an e-mail to your self.
I have send the mail with the content from the textfields, but I have made a button to get the your current location, but didn't know how to get your location and in same way also convert it to WGS84. I need to get it in this coordinatesystem, because it is used in a special sparetime activity, which uses this coordinatesystem.
Just forget the picture, the coordinate is more important.
Thanks in advance
Greetings Aksel
I'm not 100% sure if I got your question right. But you want to convert the location you get into WGS84 coordinatesm right? I'll guess you get your position via the Android LocationManager using something like: LocationManager.getLastPosition(). What you get is a Location . This location can be formated in different ways.
The questions is what exactly do you want? WGS84 is a reference system and does not say anything about the way coordinates are represented. A common representation are sphereical coordinates (also called Lat/Lon coordinates): Spherical Coordinates.
Another representation would be Cartesian coordinates. Maybe thats what you are looking for. To get cartesian coordinates you should use a 3rd party library.
Related
currently, i'm developing a map application similar to uber, and since im using Googles location service " intermitent thread " , i get the users location every 10-20-30 seconds and i update its new location on the map, by simply cleaning the existing List , and inserting another mark inside of it.
That makes it looks like the users icon is literally " teleporting " across the map.
ive made some researches and i was unable to find examples or of its possible to be done in Heremaps explorer edition.
I'm aware that all i gotta do is work with only one object instead of clearing my list and placing another object in it.
Any help would be appreciated, thanks in advance.
With the Explore Edition of the HERE SDK you can use the flyTo() method of the MapCamera. The speed and type of the animations between two distinctive coordinates can be heavily customized.
Just to give a simple example how you can move between two coordinates without "teleporting":
private void flyTo(GeoCoordinates geoCoordinates) {
GeoCoordinatesUpdate geoCoordinatesUpdate = new GeoCoordinatesUpdate(geoCoordinates);
double bowFactor = 1;
MapCameraAnimation animation =
MapCameraAnimationFactory.flyTo(geoCoordinatesUpdate, bowFactor, Duration.ofSeconds(3));
mapCamera.startAnimation(animation);
}
Whenever you set a new coordinate as target to the camera, it will instantly switch to that location - hence it looks like teleporting. With a linear (or bow like above) animation it will look smoother and in fact the coordinates between the previous and the new location are "interpolated".
With the Navigate Edition, there's also an InterpolationListener, which can be used to provide smooth interpolated location updates when a positioning source is used.
I wanted to get my current location coordinates and pass it to a String. I've tried to use googleMap.getMyLocation(); but the method is deprecated and it's not really what I need because I need literally the Latitude and Longitude coordinates in a string.
Can anyone help a young programmer :)
See this part of Android's documentation https://developer.android.com/guide/topics/location/strategies.html
I am totally new to google's maps api for android and I was wondering if it is possible to restrict the area the map is showing to one country only. I mean my target users are in my own country only and it is not useful nor logical to show them the whole world when the application logic is going to be only on this country.
Any ideas?
ps: if it is not possible in google's api,is there a way to do this with another api form another source which provides a mapping service?
If you are still interested, now it's possible to restrict the user's panning to a given area using the setLatLngBoundsForCameraTarget method.
You will need to update the dependencies for your Play Services:
dependencies {
compile 'com.google.android.gms:play-services:9.6.1'
}
You can restrict the user view to specific square -maybe- of the map, to do so, you can use the following:
private GoogleMap mMap;
// Create a LatLngBounds that includes the city of Adelaide in Australia.
private LatLngBounds ADELAIDE = new LatLngBounds(
new LatLng(-35.0, 138.58), new LatLng(-34.9, 138.61));
// Constrain the camera target to the Adelaide bounds.
mMap.setLatLngBoundsForCameraTarget(ADELAIDE);
in this case, the user will not be able to zoom in, in the map in areas where the camera is totally out of the range -square- you specified.
for more details, source: https://developers.google.com/maps/documentation/android-api/views#restricting_the_users_panning_to_a_given_area
I am pretty sure you cannot only display your chosen country using the google api service. However, what you can do, is restrict google places auto complete to a specific country, by finding your country code (e.g. using this link https://countrycode.org/) and then adding the query to your google places api e.g.
components=country:your_country_code //Insert code into example
For example, this is what is would look like:
https://maps.googleapis.com/maps/api/place/autocomplete/json?
input=bhubaneshwar&components=country:in&sensor=false&key=your_key
out of the box this is not possible. However what you could theoretically do it find the max bounding box that shows the country in question then everytime the camera moves check to make sure the bounding box is inside the max one. If it is not set it to the max. that would restrict them to a certain spot
you can override the map and specific the latitude and longitude
and zoom in with suitable for you and disable the gesture of map
see this example it is answered before
limit scrolling and zooming Google Maps Android API v2
I want to build an empty map that I can customize as I like. Now, I know how the whole system works with the tiles and lon/lat coords, but I still dont understand how to contect between my tile's pixels and the lon/lat. I want to have an empty map that shows only my country and that I can edit things the way I like (I work with Android - dont know if it matters).
Write a class which derives from the Overlay class and override the onTap() method. Then you can add your overlay to the your MapView. A GeoPoint object, which represents the position of you tap, is passed to the onTap() method when you tab somewhere on the map.
You also can use onTouchEvent(). Given the screen coordinates of the touch, you can use a Projection (from getProjection() on MapView) to convert that to latitude and longitude.
Here is a sample project.
I have a navigation program, and if there are 4 waypoints, I would like to highlight on the details list which part you are currently on, and also I could show the distance to the next waypoint and the total distance.
So, you may have:
Go right on Main Street, 1.3 miles
Go left on Broadway, .5 miles
Go left on Concord Blvd, 2 miles
But, how do I determine when a phone starts on a different waypoint.
Using the LocationManager you can set several ways for updates on a particular program. Use LocationManager.addProximityAlert() to be alerted if you're in a particular distance to a waypoint. Additionally you can use Location classes to get distance for example waypoint.distanceTo(currentLocation);.
The solution I am going with is to use a passive provider, so that if the navigator is being used then my application will still know where the user is.
Then, just keep track of where they were previously and where they are now, and look at the difference in how far they are from the waypoint, and once they get to a certain distance then let them know and change to the new waypoint.
The addProximityAlert made it difficult to know which waypoint to change to and it didn't work as well as I was hoping, and since I need to know where the user is to update their marker, there was no reason not to just add some calculations at the same time.