How to handle data for large number of pins on mapview? - ios

I am developing an App that shows a map with annotations. The annotations are in thousands and growing. There are data associated with the annotation pins. I get the data from web service. Should I download all the data for all the pins upfront? That obviously is bad. But how should I do it in an efficient way that when the user zooms in and out the map, there is no lag.
Thanks in advance!

Show pins according particular region zoom, instead of showing all pins at one time.

Related

MKMapKit and points of interest

In the Maps app for iOS, if you tap on a point of interest it displays relevant information about that POI. For example if you tap on the train station icon, it displays the name of the station.
Is it possible to replicate this behaviour using MKMapKit? The icons for the POIs are there on the map, but of course tapping on them does nothing. I've tried reverse geocoding based on where the user tapped, but this just gives me a street address, no data about the POI.
Another strategy I've tried is to use Google Places API, to load POIs within the visible map region, and then setup annotations for each of those POIs. The problem is that this API has a limit of 20 results, so it doesn't work too well in a dense area.
Anyone have any ideas on how I could achieve this?

iOS mapview and loading pin data from a web service. When to load new data

I'm currently loading data into a mapview from a web service, where there are more rows then I can return in one query. As such I'm trying to work out the best way to display these to the user.
My intitial thought is to load 100 pins when the mapview first loads. Then as the user scrolls/zooms load new data depending on where they are either in
regionDidChangeAnimated
or
mapViewDidFinishRenderingMap
The trouble is, as I'm trying to refine the places I show them based on zoom, this could get quite costly in terms of api calls. Is there a best practise here? I thought about only showing a user locations once they reach a certain zoom level, but then that could appear to them that there is actually a lack of data when the mapview first loads. My other thought was to check how far they have moved the map in regionDidChangeAnimated and making a call then depending on a threshold and zoom level.
With a tableview its obvious when to do this sort of thing, i.e at the bottom. I thought about loading results in a paged way and displaying results as soon as I get the first "page" back, but I feel that if the user is at a high level, then too many results would add too many pins to the map.
If I have access to the users location,or they provide a point of interest I think it would be easier for me to zoom to a certain scale to display results. But as I don't require this, I'm not sure what to do with the high level view. I appreciate there isn't a lot of code in this question and it sort of leans on the UX side of things. But I'm wondering from a functional perspective what's best. Even if I stored previous results in array, a subsequent api call could in theory bring back duplicates.
Anyone got any ideas on a good approach to this? So far I'm leaning towards showing X amount on load, and perhaps prompting the user to zoom to refine, the onous really is on them then to try and be more specific.

How can I add markers in offline mode using MBXMapKit?

I am working on iOS Application which requires offline map feature.
When I am trying to fetch markers in offline mode it displaying no image for any marker
even it is not calling method
[self asyncLoadMarkerIconURL:(NSURL *)markerURL point:point];
As it is only call if data successfully retrieve from URL
and so it is not update marker array for display markers.
So is there any solution to display markers as I created on my map box project in offline map (without internet)?
Two possible solutions. Mapbox marker imagery is requested from online, which is why you are seeing this behavior.
First have an internet connection so that the marker imagery is cached for later offline use.
The other approach is to manually fetch the marker imagery ahead of time to bundle with your app. Here is the section where marker URLs are formed based on desired size, color, and imagery:
https://github.com/mapbox/mbxmapkit/blob/d87e1465d196a9948381919da0c1eb8d72a242bf/MBXMapKit/MBXRasterTileOverlay.m#L124
See also standalone markers at https://www.mapbox.com/developers/api/static/.

Adding Multiple Markers To Google Map on iPhone app

I am writing an iPhone application that uses google maps SDK to display a city. I need to add multiple markers on the map to identify certain locations.
I could loop through and add each marker upon the map load, but I don't believe this is a efficient technique(it seems very unnecessarily and resource heavy!!)?
Or is there some "Lazy loading" technique I could use to pull in the markers that are currently in view?
For that you can add it in map region wise, you have to add marker only for current displaying map region, but for this also you need to run loop.
So you can avoid other markers that would added to map.

Clustering Google Maps Markers in iOS

I have a map-based application, using Google Maps' iOS SDK. I need to store up to several thousand items in a core data database and display them with markers on the map. For performance and usability reasons, I need to cluster these markers when the user is zoomed out, but I need to make sure to place representative markers so the user knows where to zoom in to see more detail.
Each entry in my core data model has latitude/longitude double values stored. So what I thought of for clustering the items is to keep a separate entity where I strip the less significant parts of the geographic coordinates and store a count in it.
So whenever an item with lat/lon {44.9382719, -130.20293849} is inserted in the database, another "cluster" object with lat/lon {44.9, -130.2} has its count property incremented. The idea is that at low zooms (ie. zoomed out), I would only query the cluster objects and place those on the map instead of the actual items.
My question is: according to the NSManagedObject reference, you're not supposed to fetch stuff in awakeFromInsert, so how can I make sure that inserting a managed object of one kind updates the value of a corresponding managed object of another kind?
I have been searching library for Clustering Markers in Google Maps for iOS for three days, and finally I ended up with this https://github.com/googlemaps/google-maps-ios-utils, which is working nicely and very easy to use and understand.
Have a look at routeMe, this comes default
/** Whether the annotation should be clustered when map view clustering is enabled. Defaults toYES. */
#property (nonatomic, assign) BOOL clusteringEnabled;

Resources