I am developing a software, some kind of GPS. It has two sides. Admin(PC) and Clients(Android).
Android version use Osmdroid maps, and what I want to do is grab the Mappoint that I created in Android, insert it to the database and than read it from other devices.
The problem is that if the actual Latitude and Longitude of point that I create is for example 42.222222 and 23.55555, after doing this:
IProjection project = view.getProjection();
final GeoPoint geo = (GeoPoint)project.fromPixels((int)e.getX(),(int)e.getY());
*e is a motion event
the actual value that is stored in latitude and longitude of that GeoPoint is 42222222 or 2355555. The coma just disappears from that values, so it is useless to usage in PC version. I don't know how the OSMdroid is working with this values, but is there any way to convert it to its standard format like -42.584254 ?
I´ve just found a solution ,it must be just divided by 1E6 :)
Related
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'm trying to create a vaadin project where the user would enter the latitude and longitude and then maybe press a button so it would find that exact location in google maps. How would I connect that to happen?
You can use the leaflet addon for vaadin. You would then create a LMarker object with the longitude and latiude and add it to the map.
Im currently working with google maps on my android app and i need to compare distances when the camera is moved. I can get the current camera latitude and longitude by using the onCameraChange method, however, im struggling with getting the cameras previous latitude and longitude. Any suggestions would be great.
I do not see an existing API to get previous location with Google Maps Camera position api
You can create a prevLat, and prevLong variables. The first time your app starts, in initialization, save the location in these variables. Use these to calculate the distance in onCameraChange, and then update the prevLat, prevLang with current location at the end of onCameraChange.
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.
I am developing an mobile application that search the user's location via GPS and display the location of the user on the google map.
I am aware that i can load a static map base on the coordinates. But is it possible to add a marker on the static map itself??
This link http://wiki.forum.nokia.com/index.php/J2ME_Google_Maps_API doesnt shows how to add a marker. So i am wondering is it possible to do so??
Any guidance will be greatly appreciated. THANKS
Kevin
If using the Google API, then there are many ways to add layers and markers; see that reference.
To use maps.google.com directly, then form the URL by adding the coordinates using the q parameter:
http://maps.google.com/maps?q=45.00,-121.00 (for +45.0 lat, -121.0 long)
Further to wallyk's suggestion, for a mobile application you may want to use the mobile version of Google Maps, as follows:
http://maps.google.com/m/?q=35.89,14.42 (35.89 = latitude, 14.42 = longitude)