How to remove map Places and annotations from MKMapKit in Objective c - ios

Hi i have an MapView in My Project i need to remove all the labels Annotations, places from MapView. Looks like Plain mapView
i tried the Following Code its working fine but still i getting some building details, Street names and all i want that also to be removed only User Location Can be Visible
here is the code:
[mapView setShowsPointsOfInterest:NO];
the above code working fine and removed default location icons from mapKit but not removing all Icons and Label, how to remove all default icons and label names from MapKit

starting with iOS 11, you can set
mapView.mapType = .mutedStandard
This removes distracting details from the map.
Apple uses this type of map, when they want to emphasise a transit route and everything else should be in the background without distracting.
Starting with iOS 13 you have even more fine grained control:
Using MKMapKit.pointOfInterestFilter you can include or exclude specific categories of points of interest.
So if you're making an App 'Best restaurants in my city', your app has its own restaurant annotations, you remove the restaurant category from Apple's point of interests, but all other POI categories are just fine for you.
https://developer.apple.com/documentation/mapkit/mkmapview/3143417-pointofinterestfilter?language=objc
Starting with iOS 16 most APIs described above are deprecated, but the ideas remain the same.
Now you set MKMapView.preferredConfiguration to a subclass of class MKMapConfiguration. These subclasses are
MKStandardMapConfiguration
MKHybridMapConfiguration
MKImageryMapConfiguration
Each of these classes have exactly those parameters that make sense for the type of map.
For example, MKImageryMapConfiguration shows no POIS and no roads, so it makes no sense that this class has parameters like pointOfInterestFilter or showsTraffic.
Classes MKStandardMapConfiguration and MKHybridMapConfiguration now have a parameter pointOfInterestFilter that has been in MKMapKit.pointOfInterestFilter in earlier iOS versions.
Old deprecated mapView.mapType = .mutedStandard is now init parameter emphasisStyle of class MKStandardMapConfiguration
P.S.
Please also have a look at the other answer of #Grimxn. Bringing your own overlay is much effort but a valid alternative.

It seems to be a bit of a kludge.
Firstly, you replace the map with an overlay of your own...
self.mapView.insertOverlay(underlay, at: 0, level: MKOverlayLevel.aboveLabels)
This can be anything. If you want to use Google Maps, or Open Street Map, you can, like this:
let url = "http://mt0.google.com/vt/x={x}&y={y}&z={z}"
//let url = "http://c.tile.openstreetmap.org/{z}/{x}/{y}.png"
let underlay = MKTileOverlay(urlTemplate: url)
underlay.canReplaceMapContent = true
alternatively, if you just want blank, give it a default layer:
let underlay = MKTileOverlay()
underlay.canReplaceMapContent = true
The parameter level: allows you to specify whether your background obscures just their background map, or the background & roads or the background & labels, but NOT above everything. The documentation says:
MKOverlayLevel.aboveLabels
case aboveLabels = 1
Place the overlay above map labels, shields, or point-of-interest
icons but below annotations and 3D projections of buildings.
I can't get that to work for the default MKTileOverlay() - it seems to do the same as the alternative .aboveRoads - i.e. it hides all of the map including roads, but not labels. When you specify one of the external overlays (e.g. google) - they DO replace the labels. Probably a bug, so the final step, to completely obliterate the labels is
self.mapView.mapType = .satellite
This removes the labels, and your overlay is hiding the satellite map. Not neat, but not difficult, either.

In case anyone is coming back to this, as of writing this, if you want literally just a map and road names, no points of interest, just use
mapView.pointOfInterestFilter = .excludingAll

Related

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.

Mapbox custom user location image

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.

How to remove an arrow from Google Maps geolocation marker (iOS)?

How do you remove an arrow from Google Maps geolocation marker (iOS)?
This is an arrow I'm talking about
If you really want to remove that arrow everywhere in your app from Google Maps SDK, it might be easiest to modify asset in GoogleMaps.framework.
Just navigate (cd) to GoogleMaps.framework/Versions/A/Resources/GoogleMaps.bundle/GMSCoreResources.bundle/ and notice the following files:
GMSSprites-0-1x.png
GMSSprites-0-2x.png
GMSSprites-0-3x.png
If you open these files, you can notice the arrow is there. So just edit directly in the asset by replacing arrow by nothing (transparent pixels).
Note: I haven't test it myself and this is not tested solution, but I believe it should work.
Disclaimer: I'm not sure, but I think this modification might violate Terms & Conditions for using the SDK. I don't get any responsibility for such modification, it's your call...
There is no way to do this with current version of the SDK (1.9.1), and actually there is an open issue with this request: Look here.
As a work around, you can hide the default button with:
_map.myLocationEnabled = NO;
Then create a custom GMSMarker
GMSMarker *pointMarker = [GMSMarker markerWithPosition:currentPosition];
pointMarker.icon = [UIImage imageNamed:#"YourImage"];
pointMarker.map = _map;
And change the position of it using a CLLocationManager, so it always show the current position. It's a bit tricky but is the only way, I could think, that you can achieve this. If you need a more complete example let me know.

OpenLayers3 - is it possible to combine modify/draw/select operations?

I've started using OpenLayers3 in my app, and so far, I have succeeded in creating working versions of:
a combined draw/modify page (based on the relevant example, draw-and-modify-features.js)
a combined select/modify page (based on the relevant example, modify-features.js)
In the case of (1), the ol.interaction.Modify instance specifies that it will work on the features inside an ol.FeatureOverlay instance:
var modify = new ol.interaction.Modify({
features: featureOverlay.getFeatures()
...
...and it is that ol.FeatureOverlay that holds all the new features drawn by the user.
In the case of (2), the ol.interaction.Modify instance specifies that it will work on the features inside the ol.interaction.Select instance:
var select = new ol.interaction.Select();
var modify = new ol.interaction.Modify({
features: select.getFeatures()
});
...and unless I am mistaken, this creates a hidden ol.FeatureOverlay that holds the currently selected feature - which is then edited.
However, I can't see a way to combine all 3 - i.e. a user-friendly way to allow a user to draw, select and modify polygons.
What I'd (ideally) want is the functionality of draw/modify, but the moment I hit and keep Ctrl pressed, the cursor is no longer working in "draw" mode, but in "select" mode, allowing me to select one of the existing polygons, and subsequently hiting Delete on the keyboard to delete it, or just edit its vertices with the mouse. As soon as I click outside all polygons, I return to draw/modify mode.
I did the naive test - that of adding an ol.interaction.Select to the interactions of the draw/modify Map instance - which lead to hilarious results :-) For example, upon finishing the drawing of a polygon (i.e. when I double-click to close it) it's also getting selected... and clicking anywhere (inside or outside polygons) just starts another new polygon edge, it never selects a pre-existing one - etc.
My only thought of a solution so far is... for me to implement a "VI emulation" :-) i.e. a "command" mode (that is, the select/modify state) and an "insert" mode (i.e. the draw/modify state) - and you chose what mode you are in from a "state toggle" button inside the map (custom OL3 control) or outside the map (normal HTML button) .
I am, however, looking for a better way, like the one I suggested with holding Ctrl...
Any ideas/suggestions most welcome.
I never found a solution combining all three modes. Since no answer came up, I might as well share that in the end, having a "modal" form of working (i.e. hitting a custom control - a map-internal button - to enter "Select Mode") is not that bad. I ended up with a "Select mode", a "Draw/Modify mode", and a "Measure" mode - selectable via map-internal buttons:
In the end, it turned out fine - in hindsight, having a "combo" mode would in fact present significant usability disadvantages.

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