How to show Map with multiple annotation in UITableViewCell? - ios

I have UITableViewController and inside my cell i need to display map with multiple annotations.
I need to show map on my tableview cell and plot multiple annotation in that map also.
Something like this Screenshot
I searched in google and couldnt get that much help.

If you don't need interaction with the map (scroll, zoom etc) you can use MKMapSnapshotter. It generates a snapshot image of the map and requires much less memory than actually using a map view. A useful link is this: http://nshipster.com/mktileoverlay-mkmapsnapshotter-mkdirections/

Another option when interaction isn't needed is the MapboxStatic library, which gives PNG or JPEG images of maps, which is ideal for table view usage.

Related

Map with annotations pins like Foursquare, swift

I am working on an app based on the Map View, and I wanted to implement something like Foursquare : in front of the map that you can scroll and that is linked with the pins.
I tried with the Collection View but without success.. Does anyone know how to do it or have an idea?
Thanks a lot.
You can achieve this by adding UICollectionView above MapView (use addSubview method or add in storyboard) and set background color of collection view to UIColor.clearColor. By this the collection view cell will look floating above the map view.

Annotation pins and detail view from sqlite

I've been looking around the Internet to find a tutorial or something to explain this.
I need to show some pins on a map. I need to get them from a sqlite database (table with POI's name, lat, lon, and some text). They have to show annotations callouts with title and subtitle and open their detail views.
All that with Objective-C.
How can I do that? Can anybody help and write the code?
I'd recommend using FMDB to get files from a local sqlite db. This stack answer is pretty helpful in getting started on that. It might take an hour to get up to speed on it, but you'll save that hour many times over once you're comfortable with it.
Now that you're able to retrieve data from your db, you need to create MKAnnotations for each pin you want to drop on the map. This tutorial is pretty short and to the point for what you're looking for. Also, don't worry about adding a lot of annotations, MapKit is optimized for have a large number of annotations on a map.
Lastly, you want to be able to go from an annotation to a detail view. MKAnnotationView has a property called leftCalloutAccessoryView where you can add a button. If you just want a quick and dirty fix, set the tag property on the button to the index in the array with the info for the detail view and have every button call the same selector.

iOS how would I implement a scroll view based overlay that can display arbitrary views at x,y coordinates

I'm working with a 3rd party maps vendor and would like to create an overlay for this map to display arbitrary content. I already have callout pins created, but am looking to expand that with truly any kind of content I want to put over the map.
From what I understand, this could be done by using a scroll view and tiling, but it has been a very long time since I worked with that. Are there any projects I can take a look at to understand how to create a scroll view with tiled/reusable subviews?
Here's how I see it working - I receive a JSON from web service, it contains a class of an item I want to display and a position. The overlay instantiates appropriate views and adds them over the map, potentially reusing and managing appearance/disappearance of components as the user scrolls the map.
Maybe there are already some mechanism built into iOS to handle overlays for arbitrary content?

showing continents programmatically in MKMapView

I have a view with 3 buttons (Europe, Asia, America) and a MKMapView.
If one of these buttons was clicked, i need to show the specific continent.
In
MKGeometry.h (Mapkit Framework)
there is a constant
MKMapRectWorld
which i can use to show the whole world.
Is there something similar for continents?
If not, what is the best way to determine all informations i need for creating a MKCoordinateRegion?
Use Google Earth or Goole Maps to work out the lat/long boundaries and then call setRegion on your map view.

How to display two annotations with the same coordinates on the map?

I have two annotations with the same coordinates. And I have to display them on the map. When I add these annotations on the map I see just one pin. How can I display two annotations instead of one? Or how can I display a annotations list by clicking on the pin? Can anybody help me?
Thanks in advance.
Igor
When you try to display multiple annotations at the same coordinate on a map using MapKit, generally it will actually place two different pins, but they will be in the exact same location. You can compare the difference in the shadow strength to see the difference, however; look at a single pin's shadow, then look at your double-pin shadow, and you should see the latter appear darker.
In terms of indicating to your user that there are multiple pins, there are several ways you could do that. You might consider implementing the title or subtitle properties on your annotations to display the number of annotations at the same coordinates (e.g. set subtitle to the string #"(and two more)" or similar). Then, when the callout accessory view is tapped, push (onto a navigation controller stack) a table view of annotations at that location.

Resources