I am creating IOS Application map based application in my app I like to show the route/path between source and destination and also I have done that but I will show only one route/path. I like to show all the possible path between the source and the destination like google map. To illustrate my idea I have added the screenshot I like to show path like this. Is there is any sample for this?
Thanks in advance
Follow these simple steps :
Get Two Input locations.
Use the method -geocodeAddressString: completionHandler: of Geo Coder class (from Core Location Framework) for getting the coordinates for the given location string.
Use MkPointAnnotation object for creating annotation on the locations in map.
Send request to the google API for getting the Direction between two locations.
As of the google API Response (Available in both JSON & XML) You would have overview_polyline object, which has the array of location coordinates. But they were encoded, you have to use the correct decoding module to get the latitude and longitude.
With the decoded location coordinates you can create the poly lines using MKPolyline instance method. MKPolyline *polyLine = [MKPolyline polylineWithCoordinates:coordinates count:[overlayPoints count]]; [mapView addOverlay:polyLine];
Now the polyline have been drawn over the map still it will not be visible as the final go we have to override the -viewForOverlay method for displaying the poly line view.
If you still have any confusions then you can always check some Tutorials.
Related
I want to know how you convert geo coordinates into an address. I have already tried the CLGeocoder class but I have no idea how to convert my data.
Thanks
You need to use the CLGeocoder Class to get a coordinate to physical address lookup. The command you are looking for is reverseGeocodeLocation:completionHandler:. You pass your CLLocation location object containing the coordinate data to look up.
Read more about it in Apple's CLGeocoder Class Reference.
I am building an application that stores locations in a list and later maps them.
The problem I'm running into is an inability to save MKMapItems to a Parse database. I need to save these MKMapItems because they are the only unique identifiers for locations on a map that would not require searching the map again (ex.location name, ex. address).
So my question is, how can I save an MKMapItem to a Parse database?
And to follow up, if it is not possible to save an MKMapItem, how else can I save these items to a map so that I do not have to re-search?
MKMapItem: https://developer.apple.com/library/ios/documentation/MapKit/Reference/MKMapItem_class/Reference/Reference.html
Parse:
https://www.parse.com/docs/ios_guide#top/iOS
EDIT
Another detail that might help: I'm using this to store information about particular venues. For example restaurants. I don't necessarily want to be creating a new map annotations at that mark if I can avoid it.
I'm not sure if Parse has prebuilt support for it, but you can definitely create your own class to do it:
1) You can create an MKMapItem from an MKPlacemark, using this init method
- (id)initWithPlacemark:(MKPlacemark *)placemark
2) MKPlacemark is basically just a coordindate and address, created using this init method
- (id)initWithCoordinate:(CLLocationCoordinate2D)coordinate addressDictionary:(NSDictionary *)addressDictionary
CLLocationCoordinate2D can easily be stored in a custom class on Parse. If you care, you can also store the relevant address values too.
3) When you need to fetch MKMapItems, you actually fetch the underlying MKPlacemark coordinates, create MKPlacemarks, and finally create MKMapItems using each.
From the server response comes to me with an update of coordinates every 5 second. This coordinates I add to map like pins. But existing coordinates of current object not removes, it coordinates just add as new. How to update coordinates of current object and remove object that have no coordinates for now?
I use native map. If you give any simple I'll be happy
The response from the server, I receive the coordinates of users if the user is, if not - nothing comes. I need an approach without removing all the coordinates and with management (delete or update), depending on the receipt of a new member eoordinaty or delete it
Use this :
[mapView removeAnnotations:mapView.annotations]
Before adding your annotation.
Hope it works :)
Twitter provides an API for getting a place object for any given location. As per twitter API documentation at https://dev.twitter.com/docs/api/1/get/geo/search :
"Given a latitude and a longitude pair, an IP address, or a name, this request will return a list of all the valid places that can be used as the place_id when updating a status.".
API returns a place object. I am specifically interested in getting the bounding coordinates for that place which can be a Point or a polygon which is included in place object. I will then use this to check if user's location lies within some other location say New York.
Now, for any user one can fetch his profile using twitter API. API returns a json object which contains user's location which is basically a string e.g, "San Francisco, CA". This location can be passed to geo search api mentioned above to get coordinates for the polygon which defines a user's location.
I am using twitter4j library to do the same. Method 'searchPlaces()' corresponds to
/geo/search API of twitter and takes a GeoQuery object as argument. However, GeoQuery object has only two constructors which take GeoLocation i.e, latitude, longitude information or ip address.
https://github.com/twitter/twitter4j/blob/master/twitter4j-core/src/main/java/twitter4j/GeoQuery.java
As can be seen in GET geo/search API, all parameters all optional. However, providing only two constructors in GeoQuery class forces one to provide either latitude and longitude values or ipaddress. What I have instead is the string for user's location from his profile.
Can someone please help me out with why there is this disparity between twitter4j and twitter API. Also, can someone suggest some other way to find if some twitter user is from New York.
PS: Any attempt to geocode user's location to get lat,long also requires GeoQuery object which again needs lat, long and I don't seem to be able to figure out how this can be done too.
Thanks in Advance.
I encountered this as well. A workaround is:
GeoQuery geo = new GeoQuery((String)null);
geo.setQuery("New York")
I created a web view to open google maps. I got no problems getting the location by CLLocationManager. However, I need to specify a query string like this: "hospital loc: [latitude], [longitude]" to put in the search box to locate the nearest hospitals. How can I implement this after I load "maps.google.com" in my web view?
Try this :
http://maps.google.com/?q=hospital+loc:+[latitude],+[longitude]
Notes :
Obviously replace with your desired latitude, longitude coordinates
Remember to properly encode the parameter passed to q=