Mapbox custom user location image - ios

I'm using Mapbox 2.1.2 where I need to set a custom image for the user location annotation. This is not a problem to implement both in MapKit or GoogleMaps but how do I deal with this using Mapbox?
If this is not possible, how can I track the user's location? I've already tried to add MGLPointAnnotation objects on location update. But then I have to have a cache of annotations and clear it on adding a new, most recent one which also leads to a "flash" ugly effect.

Background on customizing the user location annotation: https://github.com/mapbox/mapbox-gl-native/issues/2272
The best way to do this right now is to follow the guidance there, which is to customize the MGLUserLocationAnnotation class in the source code (the SDK is open source).

As of Mapbox iOS SDK v3.4.0, you can provide your own user location annotation view that contains a UIImageView. In your MGLMapViewDelegate, implement the -mapView:viewForAnnotation: method to check whether the annotation is equal to the MGLMapView’s userLocation; if so, return a new MGLUserLocationAnnotationView that contains a UIImageView. There’s a work-in-progress example of customizing the user dot in this pull request.

Related

Callout for annotation view is cut-off in macOS(Mac-catalyst) app

I am having an issue with annotation view which is shown on Map view.
The call out view on clicking on pin does not showing full address text.
Reference Image
This is working in iOS but not working in Mac catalyst app.
Please help if anyone have any idea.
Thanks all.
You are using MKPinAnnotationView which is deprecated.
Please switch to MKMarkerAnnotationView.
The new class has many advantages.

Here Map SDK IOS (Premium) tap on the marker

Good afternoon, who once worked with heremap sdk premium for ios. How do I make it possible to click on the NMAMapMarker? What they have written in the documentation does not describe it, but maybe I'm wrong.
there are different option available for NMAMapMarker to use.
This represents a marker used to display an icon on a geographical position on a map. The map handles proper placement of icons on the screen as well as panning and rotation.
+mapMarkerWithGeoCoordinates:
+mapMarkerWithGeoCoordinates:icon:
+mapMarkerWithGeoCoordinates:image:
coordinates
icon
draggable
draggingOffsetEnabled
anchorOffset
-initWithGeoCoordinates:
-initWithGeoCoordinates:icon:
-initWithGeoCoordinates:image:
-setAnchorOffsetUsingLayoutPosition:
-setSize:forZoomLevel:
-setSize:forZoomRange:
-resetIconSize
Check for more details : https://developer.here.com/documentation/ios-premium/3.18/api_reference_jazzy/Classes/NMAMapMarker.html#%2Fc:objc(cs)NMAMapMarker(im)initWithGeoCoordinates.
Please revert with your code implementation in case of any further concern.

google maps SDK iOS remove pins with animation

Is there anyway to access GMSMarkers added to GMSMapView? Default .clean() method has no animation of removing object and I want to add some. Or should I override clean()?
So I've solved my problem by storing GMSMarkers in an array and then manipulating with it.

How to determine when mapview zoom level has changed using Mapbox-iOS-SDK?

I am using Mapbox-iOS-SDK 2.1.2 and I need to know when the user changes zoom level on the map view. I know how to get the current zoom level, but I don't see any delegate methods for determining when the zoom level actually changed.
My reason is I am trying to mimic the scale dependencies functionality found in ESRI, and I only want to display annotations for records in the local data store when the zoom level is 15+.
Does anyone know if Mapbox supports notification when the zoom level has changed?
Or, does Mapbox support scale dependencies? If it does and I'm missing it, please let me know as that would save me from rolling my own version.
You can check if zoomLevel was changed in delegate method
(void)mapView:(MGLMapView *)mapView regionDidChangeAnimated:(BOOL)animated
https://www.mapbox.com/ios-sdk/api/Protocols/MGLMapViewDelegate.html#//api/name/mapView:regionDidChangeAnimated:

Custom map style in MapKit

I am looking for a way to implement a custom map style in iOS 7, just like you can do with Google Maps. I have found some posts saying that this is not possible with MapKit, but they are all posted a while back. To clarify, by style I am talking about custom colors and preferably also fonts. Example of custom Google Map style below.
(source: servendesign.com)
I would really prefer using MapKit for performance reasons, but if it is not supported I am open to using other frameworks as well. The ones that I have seen are MapBox and Cloudmade, and of course the Google Maps SDK.
Is there a way of doing it with MapKit? If not, what is the best way to go?
MKMapView also offers the possibility to use custom tile overlays. Openstreetmap has a great list of tile servers you could use to get a custom map. Of course there is always the possibility to create your own tile overlay set. The process is described in the Openstreetmap wiki here.
A possible implementation in Swift could look like this:
1. Import MapKit
import MapKit
2. Add overlays to map
let overlayPath = self.mapViewModel.overlayURL
let overlay = MKTileOverlay(URLTemplate: overlayPath)
overlay.canReplaceMapContent = true
self.mapView.addOverlay(overlay)
3. Conform to MKMapViewDelegate
class ViewController: UIViewController, MKMapViewDelegate { ... }
4. Implement delegate method to use the correct renderer to display the tiles
func mapView(mapView: MKMapView, rendererForOverlay overlay: MKOverlay) -> MKOverlayRenderer {
guard let tileOverlay = overlay as? MKTileOverlay else {
return MKOverlayRenderer(overlay: overlay)
}
return MKTileOverlayRenderer(tileOverlay: tileOverlay)
}
In the above example overlayURL is taken from the tile server list found on openstreetmap: OpenstreetMap Tile Servers.
For example if you would like to use the stamen map (which has a watercolor style) your url would look like:
let overlayURL = "http://tile.stamen.com/watercolor/{z}/{x}/{y}.jpg"
If you are searching for a dark-mode map you probably go best with Carto Dark: http://a.basemaps.cartocdn.com/dark_all/${z}/${x}/${y}.png.
See that the above URLs has no SSL support (HTTP). Therefore you will need to allow insecure HTTP requests to this specific URL by adding the App Transport Security Settings in your Info.plist. For further information have a look at this link.
MKMapView does not expose the properties you're interested in customizing. The Google Maps SDK does support custom colors and icons for markers, which may be sufficient for your purposes.
Edit: Stay tuned for iOS 11, which may offer this level of customization.
Another option is MBXMapKit, which is a MapBox library built atop Apple's MapKit, though it's geared for MapBox layers. It is separate from the MapBox iOS SDK, which is a ground-up rewrite meant to work like MapKit but not based on it.

Resources