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
Related
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 :)
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+.
I have an app (iPhone) that uses MapKit and users can create things on the map (annotations in the remote database, with latitude and longitude).
Problem is that very often users put things in the same building, very close, even in the same coordinates. So you only see the most up-to-date annotation unless you tap it and another is shown, but the usability of this is horrible. No users realize they can do that.
Therefore I guess a way to group close points and when tap, show all of them. It seems the first step can be done with clusters and I see several libraries for iOS for that:
http://cocoapods.org/?q=on%3Aios%20cluster
I would like to know if you have any idea or suggestion to solve the second problem, or the whole problem.
Thanks in advance.
Depending upon the clustering library used, you may be able to get the clustered region that is represented. Then, upon cluster marker tap, you could zoom to that region.
The JS library Leaflet has this behavior so you can see what it's like:
http://leaflet.github.io/Leaflet.markercluster/example/marker-clustering-zoomtobounds.html
I realize this is a JS library not ObjC, but just linking it for demo purposes.
I'm trying to create a map of the office I'm working at. I have a high resolution image, and would like to autorotate it in the direction the user is heading, allowing the user to navigate around the map. I thought this could be accomplished using CoreMotion/CoreLocation and a UIScrollView, but this seems like there's some work involved.
So I'm wondering if there are easier solutions for combining a custom map and direction/position on that map - can MapKit handle this for me? Are there other frameworks that can help me show a local 2D map with compass orientation on it?
You can convert your high-res image into map tiles easily with TileMill.
You should use some custom tiles with MKTileOverlay which only display at a very high zoom level (like z 18 or whatever). I suggest you take a look over at NSHipster and read what they have about it:
http://nshipster.com/mktileoverlay-mkmapsnapshotter-mkdirections/
*Disclaimer: I haven't tried this myself, came across the NSHipster article while searching for solutions to my own problems.
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.