Current Location to destination using mapview or google maps for the iphone iOS Xcode 4 - iphone

SO I am a totally new and do not know where to begin. I basically want to create a view that shows the users current location and directs them to my set location (park, concert, business, etc.). It seems fairly simple but there is so much smoke and mirrors online that I do not know where to start or how to finish. Would it be easier to call to google maps or use the mapview in the SDK?
And the bigger question is how do you do this? I mean I can create simple views and load webviews but I can not figure this out.

Use MKMapView .. its fairly straightforward to set up -- you can get the current location from CLLocationManager and pass its coordinates to the map view.
http://mithin.in/2009/06/22/using-iphone-sdk-mapkit-framework-a-tutorial

Have a look at this website http://www.martip.net/blog/localized-current-location-string-for-iphone-apps
it will help you with the current location thing.

Directions are part of the Maps application and are not available in the MapKit API. To give your users Google Maps directions, you need to use the Maps URL scheme, as documented in the Apple URL Scheme Reference. Specifically, you need to include the saddr and daddr parameters in the URL, which specify the start and destination addresses for a directions search, respectively. I believe you can pass latitude/longitude coordinate pairs (comma-separated) for those parameters, but you’ll have to experiment a bit to find the correct formatting and order.

By "direct" do you mean actually show a path for how to get there? That there is no API for. You can place a pin anywhere on a map to show people where something is, but they have to figure out how to get there themselves.
The term you are looking for to add points to a map is adding Annotations to an MKMapView.

Have a look at this website it may help you http://www.raywenderlich.com/2847/introduction-to-mapkit-on-ios-tutorial

Related

Is it possible to pass data needed for driving directions to the Bing Maps website?

I have an application that currently links to Google Maps passing it the required URL parameters needed to show driving directions for a set of points (typically 3+). This approach has worked and has allowed us to not use their API, which worked fine.
With Google, they made it pretty easy and clear by using parameters like "saddr" for the starting address, "to" for way points, and "daddr" for the destination. I could even pass in "pw" if I wanted to put the map into print mode. Simple, easy, works great!
I'm trying to determine if Bing Maps supports the same thing. I have been unable thus far to find any examples showing how this can be done, nor have I been able to easily decode the URL after creating my own driving directions using Bing Maps.
Again, I'd like to avoid using the API and am find with sending users to Bing's site when clicking my link.
It this possible? If yes, how can it be done?
Yes it is possible.
And I just wrote a little blog post to demonstrate how: http://alastaira.wordpress.com/2012/06/19/url-parameters-for-the-bing-maps-website/
Alastair's answer has full details if you follow the link through to the blog post.
But if you want the quick answer (again, thanks Alastair) use this root:
http://www.bing.com/maps/default.aspx?where1=
and stick your search destination in at the end. Eg. this gets you to Atwood Rd in London using its postcode:
http://www.bing.com/maps/default.aspx?where1=W6%200HX

How can i create a google maps URL that will bring up a map of somebodies current location, and bring them to a specific address?

For example, http://maps.google.com/maps?q=to+chicago&hl=en&sll=40.680638,-89.846191&sspn=4.715299,9.865723&vpsrc=0&t=h&z=10 will bring you from your location to Chicago, although im not sure how the geocoding works. This is going in an iPhone app where the person will need specific directions from where they are, to a given location. Its web app based, so if it works on the computer, it will work on the phone.
enternet is full of open source projects you looking. for example: https://github.com/route-me/route-me
I would set up a script that can put the address at the end of a maps.google.com query url.
maps.google.com query url's look like this http://maps.google.com/maps?q=37.0625,-95.677068
you can places whatever you want in the query ex: http://maps.google.com/maps?q=los+angeles

iPhone core location, maps navigation

I've searched quite a lot and didn't find the answer, is it possible to have a map view which will navigate to specific locations?
Like integrated iPhone map application...
I want to have 3-4 addresses and when you click on one it will show directions on map how to get there, can it be done?
No, I dont...I can google just like you :)
It looks pretty simple though - you just need to build your direction requests:
http://maps.googleapis.com/maps/api/directions/output?parameters
for example:
http://maps.googleapis.com/maps/api/directions/json?origin=Boston,MA&destination=Concord,MA&waypoints=Charlestown,MA|Lexington,MA&sensor=false
and you get back a response in this structure, and you just need to parse the JSON object:
http://maps.googleapis.com/maps/api/directions/json?origin=Chicago,IL&destination=Los+Angeles,CA&waypoints=Joplin,MO|Oklahoma+City,OK&sensor=false
Hope that helps.

Is there any easy way to duplicate the search functionality of the Google Maps app on iPhone?

I'd like to be able to search and have the results pop up as annotations just like the Maps app on the iPhone. How do I go about doing it, and how difficult is it?
You need a forward geocoder to take a string (from your search bar) and find a list of possible matches, with coordinates and such. ... there isn't one included with the MapKit (only a reverse geocoder -- from coordinates to address string). However, there's a few services out that that do this. I think GeoSimple, CloudMaps, and a few others. The one linked below is an objective-c package that pulls results from Google Maps SDK.
http://blog.sallarp.com/ipad-iphone-forward-geocoding-api-google/

Open the iPhone map application via link to Google maps with KML as query

How does one force the iPhone map application to open when the link on a web page goes to maps.google.com/?q=http://example.com/mapdata.kml?
If I open the map application and specifically put http://example.com/mapdata.kml in the query box, all the data is loaded correctly. But if I use http://maps.google.com/?q=http://example.com/mapdata.kml, the map application loads but no data is loaded and nothing is in the query box.
The typical queries work, like q=cupertino or q=[latitude,longitude]. It seems to be the kml link that's broken.
Has anyone gotten this to work? Is this supported? Do you have to URI encode the query?
Your question interested me so I did a little looking around at the Apple URL Scheme Reference. It says the following:
Although the Maps application supports
many of the Google Maps parameters and
queries, it does not support them all.
The rules for creating a valid map
link are as follows:
The domain must be google.com and the
subdomain must be maps or ditu.
The
path must be /, /maps, /local, or /m
if the query contains site as the key
and local as the value.
The path
cannot be /maps/*.
All parameters must
be supported. See Table 1 for list of
supported parameters.
A parameter
cannot be q=* if the value is a URL
(so KML is not picked up).
The
parameters cannot include view=text or
dirflg=r.
If I'm reading that right, it doesn't look like what you're wanting is supported, however, it's interesting that you can type the full kml URL into the maps app directly and have it work. That seems like a bug on Apple's part. I would just start throwing parameters at it and see what happens. That's always fun. ;-)
Best Regards,
p.s. That is a nice sticker. I'd prefer a bounty, but looks like you haven't racked up enough SO points to offer that yet. ;-)
This link will do what you want
<a href="maps:q=http://example.com/mapdata.kml">
but it will only work on iOS so make sure you check the user agent etc and use a normal maps url on non-iOS
<a href="http://maps.google.com?q=http://example.com/mapdata.kml">
The maps URL in simplest form
maps:q=GivenTitle#latitude,longtitude