I'm trying to build a mapping application that will be largely focused around custom tile overlays. Is it possible to load a map that does not contain a basemap layer, e.g. satellite or the basic map?
Desktop Apple Photos has an option to show the "grid" but that doesn't seem to exist in the MKMapType docs. Nor can you set map.mapType to nil.
Any ideas?
I haven't played with it yet, but it looks like there are some MKTileOverlay and MKTileOverlayRenderer classes that you could experiment with?
Edit
I created an MKTileOverlay and added it to my mapView to successfully remove the built-in map images:
let tileOverlay = MKTileOverlay(urlTemplate: "")
tileOverlay.canReplaceMapContent = true
mapView.addOverlays([tileOverlay])
Related
I am using Google Maps SDK in my iOS project. I am using Swift and I want to display the Google Map in UIView without any text or labels. I am able to display the map correctly but I am not able to remove the text from the map... I saw the same problem in Javascript but was unable to replicate it in Swift (How to get a map without labels?)... I want the regular type of the map (kGMSTypeNormal). Is there some way how to do it?
Its possible to hide the labels, landmarks and roads.
do {
// Set the map style by passing the URL of the local file.
if let styleURL = Bundle.main.url(forResource: "mapStyle", withExtension: "json") {
self.mapView.mapStyle = try GMSMapStyle(contentsOfFileURL: styleURL)
} else {
print("Unable to find style.json")
}
} catch {
print("One or more of the map styles failed to load. \(error)")
}
Where mapStyle.json is a json file in my project. For more detail see Google documentation.
It seems there is no direct answer for this feature yet. I can only think of 2 possible options namely:
Use Satellite view. It has no labels/texts whatsoever.
mapView.mapType = kGMSTypeSatellite;
Use Custom Tile Overlays/Layers
Tile layers (sometimes referred to as Tile Overlays) allow you to
superimpose images on top of Google's base map tiles. This is an
excellent way to add data - such as points of interest or traffic
information - and local imagery to your app. When combined with the
kGMSTypeNone map type, tile layers effectively let you replace
Google's base map data with your own.
I have an .mbtiles file and I am using it for offline map (iOS MapBox SDK). But my .mbtiles doesn't have enough data (just simple green rectangle). I want to draw some lines(roads) between points (I download it from my rest API). I found the solution to use RMShape, but I want to use already drawn map. I create my .mbtiles from osm and TileMill. Help me out please.
WhirlyGlobe-Maply SDK can help you achieve this.
It has a mapview and a globe view which you implement on your viewcontroller.
Then you create a layer using your mbtile file as shown below:
let tileSource = MaplyMBTileSource(mbTiles: "your-mbtile-filename")
You add this layer on the globe or map to display the tiles.
And using SDK's function like addShapes(), you can add, circles, vectors, labels, text and icons on the map/globe.
I tried adding lat and long lines programatically. Also tried adding some labels and spheres.
This is how it looks ->
WhirlyGlobe-Maply using mbtile and drawing on top of it
I need create an app for iOS using the GPS and MapKit. The idea is create my own map of my house for example and add it to the UIView or MKMapView and see the current position into the map.
see the image
You can use custom overlay on the map. Here is nice example of image overlay on the mapView.
Apple has provided sample code to do this with map tiles. Using the MapKnitter website you can geoposition your floor plan and export it in a format that Apple's code will accept.
Does exist any way to remove GMSPolygons from GMSMapView?
It does not seem to exist a property of GMSMapView containing them (as GMSPlolyLines), should I clear the map and render all again?
thanks
When you create the GMSPolygon you set its map property to add it to the map. To remove it from the map, set its map property to nil. This means you need to keep your own record of the polygons which you've added to the map, which you want to be able to remove later.
For example mySavedPolygon.map = nil
From google maps document
clear Clears all markup that has been added to the map, including markers, polylines and ground overlays.
So you just use
[mapView clear];
This should clear the polygons.
This has been updated, has I am using the clear function, and was looking for a way to keep the polygons while using this.
I've just confirmed against the Google Maps API Reference.
Clears all markup that has been added to the map, including markers, polylines and ground overlays.
https://developers.google.com/maps/documentation/ios-sdk/reference/interface_g_m_s_map_view.html#a28e6b8aeb7c8dc9025dc001f2a5d2c9b
How do I make a image, make it georeferenced and make it such that using the GPS, a blue dot appears where I am standing (assuming the image is there) in my iOS application. How do I approach this to georeference my image and accomplish this?
The only way to do this would be to use MKMapView. There is a property you can set, -showsUserLocation, that will show the blue dot you need.
If you need to show this over the top of a specific image... you will have to get creative with it. Maybe loading a custom image for an annotation. It can be done, just depends on how big of a map you plan to show and what your use case is. Hope this helps.
The steps I would take are as follows :
Get the user's location using a location manager
Capture the image
Instead of saving it to the disk, copy the image to a new file named something like "imageprefix_(user location's latitude value)_(user location's longitude value).png"
Put an MKMapView in your UIViewController and set
[viewController.mapView showsUserLocation:YES]
Show the image below, or above. In the future, if you're not at that location, use the latitude and longitude values from the title of the image to drop an annotation on your mapView
Good luck!