I need lat and lng of a point on a google map. It has to look like that
8.53171539306641 for example
but when I go to maps.google.com I get just
8.532493
There is a possibility to receive lat and lng that have such a length 8.53171539306641 but I do not remember how
I am sure you would have looked into this: Try receiving the value in a double precision data type.
If this doesn't solve it, could you please paste some code for us to get a good sense of what exactly you are trying to achieve.
Related
I can use place api to know what type place near.
Just like the following video teach:https://www.youtube.com/watch?v=_Oljjn1fIAc&t=304s.
My question is when I input latitude and longitude , How to do that I can know what kind of place type with latitude and longitude in android studio.
Sorry , English is so bad...
If you mean "Of what type are Lat and Lon?"
Lat and Lon are both doubles.
I want send my origin point and destination point to Google for direction.
When I use name for origin and destination it's true and returns true JSON information, but when I send latitude and longitude for origin and destination it doesn't work.
It's ok whit this URL:
https://maps.googleapis.com/maps/api/directions/json?origin=tehran&destination=shiraz&key=AIzaSyBvR07aFM-1ddGVgt392lRnUge3weT6nUY
But it doesn't work with this:
https://maps.googleapis.com/maps/api/directions/json?origin=32,52&destination=34,54&key=AIzaSyBvR07aFM-1ddGVgt392lRnUge3weT6nUY
I think the problem is the coordinates you're using - they look like they're not accessible via roads. Make sure that you're not casting the latitude or longitude to ints, you need the decimal-point precision.
Converting Tehran and Shiraz to latlngs, I get the following URL which works correctly:
https://maps.googleapis.com/maps/api/directions/json?origin=35.6887931,51.3891646&destination=29.5916593,52.583701&key=<api key here>
Hi I am new to android development.
I am on college project its based on location which is need to find list of latitude and longitude in between two points.
Given Starting position is 12.990143,80.215784 and destination position is 12.992595,80.217618.
Over the past days i search the google, i found so many links to find distance between locations and mid point. I cant able to find solution for my problem.
Please suggest some solution for this problem. I am struggling over days to find solution for this.
Thanks in advance
You can use the SphericalUtil.interpolate method from the Google Maps API Utility Library.
For example you can find a LatLng that is at 1/5 of the distance between your starting position and your destination by doing
LatLng origin = new LatLng(12.990143,80.215784);
LatLng destination = new LatLng(12.992595,80.217618);
LatLng result = SphericalUtil.interpolate(origin, destination, 0.2);
You can use the google Directions api to obtain a full PolyLine of the path. You can objain a JSON object and parse it to obtain locations in the path.
http://maps.googleapis.com/maps/api/directions/json?origin=12.990143,80.215784&destination=12.992595,80.217618&mode=driving
This will return a full JSON result which contains everything you would need to find the whole route to all the points falling on it.
You can look more into it on:
https://developers.google.com/maps/documentation/directions/intro#Introduction
I want to make an android application to get weather forecast using openweathermap I from the website, I see that the URL is written like this :
[api.openweathermap.org/data/2.5/forecast/daily?lat=35&lon=139&cnt=10&mode=json]
I want to add my current location as longitude and latitude instead of constant values; I got the longitude and latitude of my current location; but I don't know how to add them into the URL.
can I use val[longitude]+val[latitude]??
If you are using java.net, yes you can do it just in plain string as:
URL urla = new URL("api.openweathermap.org/data/2.5/forecast/daily?lat="+val[latitude]+"&lon="+val[longitude]+"&cnt=10&mode=json");
I highly suggest to add org.apache.http to your project. It will make doing api call far easier than in vanilla Java.
Do you have any experience in Java? Cause I don't know if I understood your question properly.
Assuming the latitude and longitude are doubles for coordinates like this.
You'd write:
double lat, lon;
...
String newURL = "api.openweathermap.org/data/2.5/forecast/daily?lat=" + lat + "&lon=" + lon + "&cnt=10&mode=json";
That being said, this is a very basic question. I'd recommend you do the following java tutorials at
http://javala.cs.tut.fi
That system is able to grade you and I'd suggest you try to get at least 90% of the points on it.
You could try using the org.apache.http library as suggested by Arthur, but I'm afraid you might not get far if you haven't memorized the simpler Java constructs yet.
Does anyone know how to display points, lines etc. (basically every overlay) created in android in standard google maps on website? The android db is synchronized with remote db. I'm getting the points from the database, creating kml file from them and uploading in to the map. The problem is that the areas I've created are not appearing where they should. They're somewhere on the ocean. I thought that's because I'm running this code in android:
Double lat = location.getLatitude()*1E6;
Double lng = location.getLongitude()*1E6;
So basically I'm doing microdegrees here. I thought that dividing lat and long from db by 1E6 would do the trick but it didn't. Can someone please help me on that one? Thanks in advance.
I don't know which format is expected by the map.
If it is normal coordinates, then I guess you would need to do:
float lat = ((float)location.getLatitude()) / 1E6;
Otherwise, if it is expecting it in int format, you don't need to do anything
P.S. Assuming getLatitude() returns an int, the cast to float is important. Otherwise 4539845 will become 45 and not 45.39845
I agree with ltsik, the E6 format is basically the regular latitude multitplied by 1E6 (or 1,000,000 whichever one you prefer) so it makes perfect sense that the variables lat and lng are obtained by dividing and not multiplying