MKMapKit true distance between two annotations - iphone

I want to make a application that calculates the distance between the user's current location and the nearest something (store, whatnot). Is there any way to obtain the real distance (following public roads ) instead of a direct distance (line from point A to B) ??
Thank you

Use google API to get the route and distance:
http://code.google.com/apis/maps/documentation/directions/
I don't think you can get the route (following roads) from MKMapKit.
The google maps API will return the route (following roads) as a set of latitude and longitude coordinates. It will also return the calculated distance.

Related

(Flutter) How can I use Google Map's distance matrix API to calculate the distance between 2 locations using the names of the places

I'm trying to find the distance in meters between 2 places using the google maps API in flutter. I was asked to use names of cities or places and I have no idea on how that works except using longitudes and latitudes. Please how do I go about it.

Creating a Dynamic Google Earth Web Link

I've been tasked with creating a Google Earth Web link programmatically when given coordinates. I have the street address as well, where I'd ideally like to drop a pin.
For example, I can get a link to the white house using its lat/lon at a distance of 150 meters like this:
https://earth.google.com/web/#38.8976633,-77.0365739,150d
If I search using the google earth web app I can generate a link with a pin, where a few of the parameters in the link change slightly:
https://earth.google.com/web/#38.8976763,-77.0365298,18.0497095a,800.41606338d,35y,0h,45t,0r/data=ChIaEAoIL20vMDgxc3EYAiABKAIoAg
Am I able to dynamically generate the data element, or whichever element creates the pin, at my desired location? I've also had trouble finding the correct distance d and elevation a parameters in my links.
As you found, you can generate links to specific views in the Google Earth web client by adding the correct parameters to the URL, including the latitude, longitude and altitude (a) of the view target, and the distance (d) of the camera from that target. Note that altitude and distance are both in meters, and altitude is above sea level, not above ground elevation. If you look at the a and d parameters that Earth puts in the URL as you fly around, often altitude will be the terrain (or builing-top) elevation at the target lat/lon, and the distance will be how far the camera is from that altitude. The other available parameters include heading (h) and roll (r).
So long as your tilt (t) remains zero, then altitude and distance should be interchangeable, or if both are >0, then they will be summed together for the final camera height above sea level. But if you add a tilt (zero degrees is looking straight down), then the altitude determines the elevation of the view target (above the lat & lon location), and the distance determines how far the camera is from that point. If you make d=0, then altitude will define both the view target and camera height above sea level. If you make a=0, then the distance will be from the lat,lon at sea level (even if that's underground).
Unfortunately there's no way to manually construct the data parameter, as it can contain many different things. To do that right would require an API, which Earth for Web currently does not provide. Hopefully that kind of functionality will come after Earth finishes its work to become cross-browser compatible via Web Assembly. Until then, there's not a way to add a point the map via just a URL.

How to implement a geo route fence

Say I keep getting a set of Geo coordinates from a moving vehicle.
There is a predefined route that the vehicle needs to follow from Point A to Point B.
The route will be defined by giving the user the option to select points A and B and also selecting the WayPoints in between and letting the Google API select the best route.
As the vehicle moves I need to check whether the vehicle has deviated more than 50 m from the predefined route.
My solution (not fully tested)
When the user has selected the start and the end points and the waypoints in between, I can make a call to the Google Directions API which would give me all the points on the road in between
(The polyline property inside the steps gives you the exact points on the road which the UI uses to draw the lines. You can call the following URL to see the polyline response
https://maps.googleapis.com/maps/api/directions/json?origin=Boston,MA&destination=Concord,MA&waypoints=Charlestown,MA|Lexington,MA
)
and store these points in some database (Mongo) with a route id.
When I get the geo cordinates from the vehicle I can make a query to Mongo asking for all those points with the route id and whose distance is less than 50m from the vehicle coordinates. And if there are non then the vehicle has deviated from the route.
Is there a better way of doing this?

Get coordinates for highway kilometers in Germany

Is there a way to get LON / LAT coordinates for German highway kilometers? I am looking for a search-string in the Mapbox API
i.e.: Autobahn A5, Kilometer 214 ==> bab+5+km+213+DE
https://api.mapbox.com/v4/geocode/mapbox.places/bab+5+km+213+DE.json?access_token=TOKEN
General bypass assuming the use case for having km mark on highway is if it's associated with some interchange on it: Let's assume we don't have such ready for use easy web API. So we need to build our "reverse geocoder" from km mark on highway to it's lat/lon.
We always have from popular GIS API's (Google maps etc.) coordinates for Interchanges, and of course we can order them.
Key point: In order to drive between 2 adjacent Interchanges, any decent routing web service algorithm (Google maps directions etc.) will always direct you to drive on that highway. It's logical... (with param like "shortest route" in case live heavy traffic and it will try to redirect you).
What I suggest is:
Let the first Interchange of the highway to be 0 K.
Ask for directions to the second interchange -
You will get the distance - so you know what is the km mark for the second interchange.
And so on to cover the highway until the km point you need.

how can i get distance bettween two place?

hello i want distance between two place ... means i have two places latitude and longitude then i want distance between that two place
i want something like this...
http://maps.google.com/maps?saddr=23.029772,72.527871&daddr=23.1901748,72.0127743
not like php or .net or java function that give calculate distance ...
if i search result by function it give me 55.61 output for this latitude and logitude and in map it give me 65.5 output. how can i get this in json ot xml or any other formate ?
...there's an in-built function in iOS that will do this for you. Check out the CLLocation documentation. Particularly distanceFromLocation:, which as the name suggests returns the difference between two locations in meters. You can create a CLLocation object using lat and lon.
If you don't want a straight line distance, you need to use the Google Directions API, which is well documented here: http://code.google.com/apis/maps/documentation/directions/