How to know a location ( like : (CLLocation *)newLocation)) whether on the road? - ios

I was doing a map ios app using CLLocation and I was wondering whether there is an API for judging whether a point on the map is on the road, but not in an appartment or in anywhere in-side the house?
I have seen there are certain navigation application who can keep the points on the road.

https://github.com/route-me/route-me
Have a look there are so many example in this code you will an google api which provides us the route path latitude and longitutude and we draw a over lay on the map.
Hope this will help you.

Related

Swift: Maps: How to tell next intersecting street on my route

I am writing an iOS app in swift. I need to be able to tell at any given point in time what street will be intersecting next on my user's route who is driving/walking.
I am able to find the street name user is currently on, the direction user is moving in and also the current coordinates but the last step stumps me: which street will intersect next?
I am open to using Apple Maps, Google Maps, OSM etc as long as it if free.
Your best bet is to use https://developers.google.com/maps/documentation/directions/
The idea is to get the legs of the directions and then determine in which leg you are currently in which you can do since you know the current street name you are in and then find the info about the next leg. It may not always be accurate but its the easiest way that you can find which street will intersect.
You can either use the Driving or Waypoints api.
Hope this helps.

How to find time duration of covering a distance between two points

I have drawn a route between the source point to the destination point and I have also found the distance between them by using CoreLocation Framework method "distanceFromLocation", but now I want to find time duration of covering a distance between these two points.
I have seen many guidelines but I have so far failed to get any solution. Can anyone please guide me to a solution or help answer how to do this?
Thanks in advance.
You probably want to build a route from source to destination point. You can do it either using Apple Maps or google maps. If you choose apple maps then you need to construct MKDirectionsRequest object (see documentation). When you get a response you can check routes that Apple suggests you in MKDirectionsResponse object. Each MKRoute object has an expectedTravelTime property

Showing route to a certain location on a MKMapView iOS?

I'm working on a app that involves a MKMapView, and I need to show a route from the User's current location to a certain location. I've played around with the MKMapView, and I can't find something that would show a route. Any ideas?!?
P.S., If I could also get help on finding out how far apart those two locations are, (User's Location and Certain Location), that would be even more awesome!
Thanks in advance!
For the distance, you may use CLLocation:
- (CLLocationDistance)distanceFromLocation:(const CLLocation *)location
MapKit can give you directions using the MKDirections class. But that is only available for iOS 7 and higher. For older iOS version, you need an external framework/API to calculate the route for you, e.g. Google Directions.
To display a route on the map, you would use Map Overlays (probably MKPolyline and MKPolylineView).
Try it: https://github.com/kadirpekel/MapWithRoutes
Its work for me. But you must do some changes.
There is no way to automatically show a route in an MKMapView. There is support for it in iOS 7, but it's a toolkit of components, not a ready-made feature. It will take a fair amount of development. You will have to query the location manager for route information, then create an overlay layer with polylines based on the route information you get back. I haven't tried this, but I've read about it in the Xcode docs for iOS 7.
The simplest thing to do is to invoke the maps application to display the route for you. That only takes a few lines of code.

Get the distance from the current location to the final destination by road like in Apple's Maps app

I want to set start location and final destination and get how long it actually is via the roads, like in the map app. I don't know what I'm supposed to search for or what it's called. I think Mapkit is the right framework but I can't seem to find what im looking for.
Sorry dude, but MapKit doesn't have this functionality built into it.
You're best off using the Google Maps API https://developers.google.com/maps/documentation/directions/#DirectionsResponses which gives you distance and driving directions.

Bing API for finding nearby cities

Is there a Bing API for finding nearby cities given a city name or lat/long combination?
I don't know if Bing provides this, but you build your own from the data available from geonames.org
They provide an API to get places near a given lat/lng: http://api.geonames.org/findNearby?lat=47.3&lng=9&username=demo
Or you can also go all out and implement a solution for your own needs using their data, as per this answer: Given the lat/long coordinates, how can we find out the city/country?
I think this is what you're looking for: Bing Maps API Sample
The short answer is no, there is no Bing API for finding nearby cities.
That said, it would be possible to 'cook your own' using the existing APIs. However, one thing that would need clarification is what 'nearby' means. I presume you mean within a specific radius of a given point (determined by a city name or lat/long combination).
Using the Bing Api it would be fairly trivial to implement an algorithm to reverse geocode a location and then test for places within x distance.
Failing that, you could use something like geoPlugin, it is free and you can put it on your sever - thus avoiding 3rd party up-time issues.
http://www.geoplugin.com/webservices/php#php_class
Take a look at the nearby places features, this does exactly what you want.
http://www.geoplugin.com/webservices/extras
No, there isn't. However, it's relatively simple to get the bounding box for a given coordinate and then use the Bing Maps API with that. I'm doing this and used this solution to get what I needed...
https://stackoverflow.com/a/14314146/73680

Resources