How do you cluster annotations with v10 of the MapBox iOS SDK? - ios

How is clustering done with v10 of the Mapbox iOS SDK? And can I use ViewAnnotations to show custom views for clusters?
In short, I am trying to cluster annotations on a Mapbox MapView, and show a custom UIView at each cluster. Something like the example shown here in the Mapbox documentation for v6.x.
After looking through the iOS SDK guides and the documentation, it's unclear how to do this. There's even a section called "Migrate to v10", which seems to cover all the differences between v6.x and v10, except for how to cluster data. Before v10 of Mapbox (with v6.x), it seems you would use MGLPointFeatureCluster, but I can't find anything covering clustering with v10.
Thanks in advance!

Apparently, this feature is now built-in. I added a variety of annotations in different locations and it automatically grouped them into clusters when zooming in/out. No custom code is needed :)

Related

How to add big image as overlay in latest MapBox version(v3.2.2)?

I read here that it's possible to add big custom image as part of MapBox.
But now i'm trying to find out how it can be implemented in latest SDK version, and it's seems like there is no such option.
Is it possible to achieve this?
It is possible. You will need to modify your own Mapbox GL Style.
One way to do it is from Klokantech
This project from github.com/klokantech can show you how to structure your Mapbox GL Style.
Mapbox also has some great resources
Option 1 — upload your raster to Mapbox Studio
Option 2 - Please check out the example from Mapbox. Custom raster style. Use legacy raster tiles on a map.
This screen cap gives an example of how I've done it in the past for iOS. This example serves up local PNG's in an iOS app.
If you’re looking to place a geo-rectified image onto a map, that isn’t possible yet with the Mapbox iOS SDK.
Using annotations for this purpose (view-based or GL-based) isn’t quite supported yet, either. Once view-based annotations completely support flatness and ignore map rotation, that may be an adequate workaround. Look for those features in v3.3.0+.

Show particular area shaded in MapBox

I am using the MapBox iOS SDK for my project. Now I want to show shaded area in the Map for a particular area like any country, any continents etc. So how can I implement this feature.
Your suggestions and response will be helpful.
You can either do this client-side with something like RMShape or server-side by either shading things on the Mapbox.com online editor or making a custom map to upload with TileMill. The Mapbox site has lots of documentation on doing these things.

MKMapView clustering if too many Map Pins nearby

I'm wondering if any of you knows a method (library, category, etc.) to cluster iOS MapAnnotations if there are many of them at the same location (e.g. 4 pieces in about 10m).
It doesn't matter to zoom in because they are still overlapping. I've already tried https://github.com/applidium/ADClusterMapView (and sombe other libs) but all of them are made for showing clusters in zoom-out-scenarios. None of them really respect the distance between annotations when zoomed in.
I'm working on an app with an offline-db so a server-side solution is not an option.
thank you for your help!
You don't need 3rd party framework's anymore. iOS 11 has native clustering support.
You need to implement mapView:clusterAnnotationForMemberAnnotations: method.
Get more details in the Apple example: https://developer.apple.com/sample-code/wwdc/2017/MapKit-Sample.zip
You should have a look into CCHMapClusterController project, looks exactly like something you are looking for.
One alternative is the MapBox iOS SDK, which is an open source (BSD) library replicating MapKit behavior. It does both annotation clustering and offline map layers.
http://mapbox.com/mobile

How to dynamically draw maps

In an iOS application, I want to draw a United States map with states and counties outlined. I also want to draw individual states with counties outlined. I have researched using Shapefiles to do the drawing, but I can't find a good API that translates shapefiles. I have looked into ArcGIS, but it seems most of the drawing they do is web/server based, also without the ability to draw individual states, or outline counties.
Does anyone know of a good iOS API I can use to draw the following maps?
United States with states and counties outlined
Individual state with counties outlined
Take a look at MapBox, it will let you draw these types of maps, then you can pull them in as tiles and overlay them with MapKit.
They also have an iOS SDK, http://mapbox.com/mapbox-ios-sdk/ if you don't want to use MapKit.
I think ArcGIS for iOS is your answer here. The iOS API will allow you to add a MapView to your application.
You can add one or more geoservices to that MapView, as well as local graphic layers.
MapServices are rendered server-side. FeatureServices are rendered client-side. You can also take features (each county or state would be a feature) from the FeatureService and put them into the graphic layer to implement different effects such as selection, outlining...
If you want to have all data stored in the client (the device), then you can embed the json representation of the features and add them to the graphics layer in the MapView, without needing to connect to any geoservice (although geo applications work better when connecting to a server)
Start here: http://developers.arcgis.com/en/ios/sample-code/
This sample looks similar to what you are looking for: http://www.arcgis.com/home/item.html?id=417a0bf9dfda482c8110ebdbde3edd66
This also looks promising: http://developers.arcgis.com/en/ios/guide/cloud-storage-feature-services.htm
All good answers above. The solution that ended up working for me was to simply use an SVG image, drag it into PaintCode and PaintCode gives me all the code to draw the image. A very simple and elegant solution.

Subclassing MKMapView to provide custom maps?

I'd like to provide custom navigation maps in my iOS 6 application. I've tried adding overlay views that shows these custom maps in MKMapView and it didn't work well because it needs a higher zoom level than what Apple's component can provide (the desired zoom level is about 10 screen points per meter in the map).
The question is, is subclassing MKMapView a good way to approach to this? The primary reason is I'd like to take advantage of MKMapView's coordinate conversion functions:
convertCoordinate:toPointToView:
convertPoint:toCoordinateFromView:
convertRegion:toRectToView:
convertRect:toRegionFromView:
Those functions makes it easy to convert screen points to world coordinates (latitude/longitude) and vice-versa.
Thanks in advance!
I don't think you are going to have much luck with subclassing MKMapView. There is a lot going on behind the scenes related to tile loading that you cannot access.
I would guess you would be better served using something along the lines of the MapBox iOS SDK or another similar map engine.
It allows you to specify your own tile sources and has plenty of examples to show you how it is done. It also had functions, like map kit, to handle converting values to and from lat/lon.

Resources