In our iPhone app we need to draw a route on Google Maps (GMaps is the only option, we can't consider other maps).
We draw the route while the user walks around - GPS tracking basically. Then we display all saved routes on the map. The problem is that Google Maps is almost unusable. It is impossible to scroll the map, zoom it (everything is extremely slow).
Now we draw the route on a transparent layer [UIColor clearColor] in the method
- (void)drawRect:(CGRect)rect
which is called using [ setNeedsDisplay] through UIGraphicsGetCurrentContext.
Our task is to draw a route (almost like in native iPhone GMaps app) so that the map will be scrollable and easy to zoom and the route won't be glitchy.
As an example of what we need to do I can point to this app http://itunes.apple.com/us/app/endomondo-tracker/id333210180?mt=8
Maybe you can point me to any of the libraries that do this?
Thank you for your help.
You might want to have a look at http://github.com/mobilemelting/nvpolyline
This solution is especially targeted at iPhone OS versions prior to v.4.0
Although it can also be used in v.4.0
Hope this helps.
Related
IN my project I need to draw a route between two pins. Can anyone tell me what are the methods used. And give me the example code for that.
Try these posts.. It will help you i think
http://navarra.ca/?p=786
http://spitzkoff.com/craig/?p=108
This will automatically use Google Direction API and will fetch the points in between the locations i guess..
Anyhow see this blog http://laurilarjo.wordpress.com/2010/10/23/using-google-directions-api-and-drawing-routes-in-iphone-mkmapview/
You can use MKPolyLineView - it allows you to draw a line (or polyline, if you need several segments) as an overlay on top of the MKMapView. Apple even has example code using this here.
Note that this method uses an MKOverlayView which was added in iOS 4, so it only works in iOS 4+. If you need to target iOS 3 devices, then you can use the MKAnnotationView hack that others have linked to (originating as far as I can tell from that spitzkoff blog post). I used to do it that way, but did away with it when iOS 4 had matured enough - I'd wholeheartedly recommend doing it the new way if you don't need iOS 3 support.
As for pins, use MKPinAnnotationView
Go to google maps. "Get directions". Make a screenshot. Then use UIImageView. This is what I would do.
How can an image overlay be applied to a MKMapView? Basically, when you zoom in a specific location, I want an image to appear on top of the map that gives a more detailed view of the location.
I've had a look around and found different types of methods to use. I had a working example for an older SDK using the DrawMapRect function but this no longer seems to work on 4.2.
This is a good place to start...
http://developer.apple.com/library/ios/#documentation/MapKit/Reference/MKOverlayView_class/Reference/Reference.html
I was looking for polygon sample code though.
#omniscian: If you have solved it you should post something helpful for others. This page has a high google rank.
I already have a tile source set up for use with the Google Maps JavaScript API. I am trying to translate this for use with the iPhone MapKit. I have correctly implemented the javascript zooming levels into mapkit. Whenever - (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated is called, I snap the region to the nearest zoom level based on the same center point.
Is it possible to implement a solution possibly with CATiledLayer to implement a tiling solution. Does the iPhone use the standard 256x256 tiles like google maps does natively? Any direction or help on this would be greatly appreciated. I would rather not waste a couple weeks trying to implement this if it's not possible.
FWIW, I spent quite a bit of time looking for a decent solution… before diving into a CATiledLayer example, I noticed MKOverlay and MKOverlayView — which are new in iOS 4 and plug right into a MKMapView.
Couldn’t find a good example implementation of using MKOverlays that pull arbitrary image data (say, UIImages from a remote tile server), but I tinkered around with the API enough until I got it working.
Built a simple example implementation of it in case anyone (like me) wants a reference:
http://github.com/mtigas/iOS-MapLayerDemo
Hope this helps someone out in the future.
MapKit doesn't provide much in the way of custom tile sources (in fact, it provides absolutely nothing to customize sources: you either use Google Maps or you don't). I've been working with a similar problem myself, though, and I've found RouteMe to be a pretty good solution for custom maps: http://code.google.com/p/route-me/
Built-in support exists for OpenStreetMaps, OpenAerialMaps (which is currently offline), Virtual Earth, and Yahoo Maps, but the framework makes it pretty easy to plug in your own tile source, too.
Yes, since iOS 7, MKTileOverlay will do:
https://developer.apple.com/library/ios/documentation/MapKit/Reference/MKTileOverlay_class/Reference/Reference.html
I want to you iPhone LocationManager and display the position using a custom map, different from the one used by MapView. Is there any way to customize the MapView or should I rebuild my own MapView from scratch ?
Do you think MapView will be open to achieve this kind of customization in a future release of the SDK ?
Do you have any recommendation to rebuild a MapView from scratch. I will have to divided my map in level and each level in tiles. But should I associate a tile with an UIImage or should I build/manage dynamically an UIImage composed of tiles currently displayed ?
Please make sure you file a bug with Apple, asking for this feature (I already have). In the meantime, I think your best bet is to take a look at the route-me library. It emulates the built-in Google Maps application, but uses either OpenStreetMap, Microsoft VirtualEarth or CloudMade as a data source for tiles. You could add support for loading tiles from your own custom service.
I'm with building a map application for iPhone, and I wanted to ask what the best way is for bringing maps from a website onto the iPhone.
I want to fetch small images of size 80x80 and show them. This kind of activity might be achieved by using UIKit or OpenGL ES.
Also if you can bring to my notice some kind of achievement and guides for this thing, I would be really very thankful.
EDIT:
I need to get the custom maps for some other vendor..
Besides that i know how to get the images its the rendering part and displaying part that what my problem man.
For small static maps, you could use Google's static map API
You can construct a URL to get your image like this:
NSString* urlString = [NSString stringWithFormat:#"http://maps.google.com/staticmap?center=%f,%f&zoom=%d&size=%1.0fx%1.0f&key=%s&sensor=true",
aLocation.coordinate.latitude, aLocation.coordinate.longitude, // aLocation is set to the center of the map
kCardBackGoogleMapsZoomLevelDefault,
80, 80, // your map size
kAIGoogleMapAPIKey]; // your google maps API key
All the other maps suppliers support static tiles - Microsoft, Yahoo and CloudMade.
Take a look at this topic: http://discussions.apple.com/message.jspa?messageID=8157498. It's nearly the same as what you're asking for.
As far as displaying the scrolling map is concerned, CATiledLayer would be the way to go. It's a slightly complex class to use, but you can find some examples if you google it.
Would you be able to use iPhone SDK 3's MapKit API, or do you need to use custom maps?
If you have a set of custom tiles you want to load, you may want to look at mapping engines put together by companies like MapNinja that let you use your own tilesets.
Otherwise it's a lot of coding to do something like a tiled map engine yourself.
If you're looking to just embed a single, non scrollable map, then have a look at the Google Static Maps API, which will generate map images for you on the fly, depending on your request parameters.
If you want to implement a slippy map, then either try route-me, which works with OS 2.2.1, and supports custom tile servers. Or have a look at MapKit/Google Maps in OS 3.0.
You could also use the Route-Me project
http://code.google.com/p/route-me/
BSD Licensed - perfect if you need to render your own tiles