I'm in the process of making an iPhone App that can show nearby stores (the stores are a danish grocerychain of stores). In the app. I want to switch to a view where the standard iphone map is shown and I know how to make that and a pointer of my location.
Now i have a list of all the addresses of the stores. But i don't know how to make the map automatically show for example 4 or 5 of the nearest stores of my current location.
Also I would really like that when the map launches it doesn't show the entire world but it automatically zooms in on my current location in a decent way :)
I hope someone will help. I would really appreciate it :)
What you want is not as simple as flipping a switch, but it can certainly be done:
Fetch the list of nearby store locations based on the current location of the device. Use Core Location to get the current device location and then fetch the nearby stores from either a file within the app bundle or from somewhere on the web
Display the stores on a map provided by MapKit using annotations. To make sure only a relevant part of the map is show use the setRegion:animated: method of MKMapView
Related
I am developing an app that will take in two locations from the user, one of which can be the standard 'current location', the second will be a location of the user's choosing. First of all, I simply want to plot these two locations on a map view.
Can anyone help me take a place name (e.g. Boston MA) from the user via a textfield and get the decimal coordinates as well as dropping a pin on the map?
Read the Location Awareness guide, especially chapter
UsingGeocoders
This will deliver a coordinate for given free text.
Further search in the Apple Developper Center for Demo code for that Geocoder.
Further there is a LocateMe demo code from Apple, which uses the map (MkMapKit)
I am implementing map based application in iPhone sdk. I want to give functionality in map view like Google maps directoins. means is at some location from that he selects one pin from multiple pins from MKPinAnnotationView. is it possible that user can get direction from his current location to selected pin location in MapView? user can select any aanonations from that he can get directions in some way of line to his current location to pin location. i have get some idea from here
but this all was some static data you can download this example.
here also apple example. but this example is only for track & draw line for user movement.
is it possible that user can get direction from his current location to selected pin location in MapView?
Yes. You can send a query to google maps api using your current location and the selected annotation location. When google responds with the route, you will use that polyline decoder method to decode the data and draw the route on your map view.
I have got all side idea from here
this can be useful for other developers also.
i have found some other examples also that can be also useful for other developers just google. you will find this is polyline link for user current location use this apple code
Here is Google direction api. Read it and use it.
For test purpose you can check this request
http://maps.googleapis.com/maps/api/directions/json?origin=28.459497,77.026638&destination=28.435600,77.009997&sensor=true
And use JSON Viewer to see the json response.
I'm writing an app that stores the location of the places you have been throughout the day. I've done a lot of research on CLLocationManager, and have been testing my app for the last 3 weeks. The locations I get with CLLocationManager sometimes is very inaccurate, sometimes 4 or 5 miles away from where I am.
I have a log in my test app and realized that every time I get a new location my DidUpdateToLocation method is called 3 times in a row, like within one second, and I get 3 different locations. One of them is always right, but the other 2 are off. I've tested with it with different accuracies(hundredMeters, nearestTenMeters, and Best), but still had the same problem. So, my first question is:
Is there anyway I can find out which of these locations is the right one so I can store it?
I've also realized that the user's current location on the map view is always very accurate, so I thought about getting the user's location from the mapView(blue dot) instead of the CLLocationManager, but I learned that a mapView object will only return the current location if the map is actually on screen, and this is not the case since I want my app to run in the background. So the second question is:
Is there anyway to get the user's current location from a mapView without the map being on screen? Or at least use the same technique the mapView uses for finding the current location?
If you have any experience with mapKit and CLLocationManager, please share your thoughts.
Thanks for you time. Any help is appreciated.
Is there anyway I can find out which of these locations is the right
one so I can store it?
Look at the horizontalAccuracy property of the locations that you receive. Don't use locations that are less accurate than what you're looking for.
I've also realized that the user's current location on the map view is
always very accurate
The map view probably doesn't have any special access to API's that are more accurate than what you've got, it just uses them better. Instead of starting from scratch each time you need a fix, try caching the location and then updating when you get a new location that's sufficiently accurate.
Take a look at Apple's sample code Locate Me. It uses the variable:
CLLocation *bestEffortAtLocation;
to determine upon updates if the location is less than the last location and less than a time limit set until the most accurate location is found.
In particular look at the GetLocationViewController in the sample code. I've used this code in my apps and it works great.
https://developer.apple.com/library/ios/#samplecode/LocateMe/Listings/Classes_GetLocationViewController_m.html#//apple_ref/doc/uid/DTS40007801-Classes_GetLocationViewController_m-DontLinkElementID_8
I would like to develop an iPhone application and I have a problem witch is:
a have a web services witch deliver for me the longitude an altitude of my objects.
a would like to use a search bar and a map, when I tape for example Paris, I would like to see all my objects in the map.
Is this possible to do? If YES how I can proceed?
Store your objects from the webservice.
Search for a location.
Display the search location in the map.
To show annotations in the map with your objects, see how-do-i-determine-if-a-coordinate-is-in-the-currently-visible-map-region
I am working on an app that will show the user the closest locations from a database to the user. When the user selects one of these locations from a list, the user will then see a map on a new screen showing an annotation representing the user, and another annotation representing the location.
Is it possible using the MapKit API to show the user a path from the user to the location? I am not asking about how to show turn by turn directions. I just want to display a path between the two annotations. Is this possible?
In iOS 4.x, Apple added support for map overlays. It might help to read a little bit more about the MKPolyline & MKPolylineView classes and the mapView:viewForOverlay: method defined in the MKMapViewDelegate protocol. All available in the Map Kit Framework Reference.