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.
Related
My goal is to have an app where I can scan a certain image and display an AR-Generated Model next to it. I am following this project.
I already imported the image I want to scan and that is working as expected. The problem now is to import my own Model. And that is where I struggle.
What I want is to display a 2D Image on a simple PlaneScene on top or next to the detected image.
I managed to create a .dae file from Blender. I also imported it into Xcode and converted it inside XCode to a .scn file.
This is how it looks:
As you can see the image is not correctly displayed.. It is just white. Also when running the app, the Object is not being displayed. I can not see it anywhere, but it is also not throwing an error.
This is my .dae file: File
Maybe I dont even need Blender for that but I couldn't find a way to display an image onto a Plane in XCode...
What am I missing here? I feel like there is something wrong with my Model. Any help is appreciated!
As I can see, when I open your file in Blender and go to the Front view:
Your Plane is wrong oriented in the space. One looks at it from the side and it is not well centered. (but this is probably what you want).
But you don't need an imported geometry object. Apple has a solution to this.
I recommend you to use the built in plane (SCNPlane, what is a SCNGeometry object) for your project. It will have a front view oriantation by default and you can easely move the offset position.
Let me know if you need an example. But it should be easy to find out how to do this.
PS: If you want to import Models this here is a useful extension to do this:
extension SCNNode {
convenience init(named name: String) {
self.init()
guard let scene = SCNScene(named: name) else {return}
for childNode in scene.rootNode.childNodes {addChildNode(childNode)}
}
}
I use google maps for my iOS app which primarily displays custom tiles.
I subclass the GMSSyncTileLayer and request the tile using URLSession.shared when I get the data back I pass it to the receiver like this:
let image = UIImage(data: D) ?? kGMSTileLayerNoTile
receiver.receiveTileWith(x: x, y: y, zoom: zoom, image: image)
This is correct according to the Google maps documentation and it successfully renders my tiles:
However, the instant the user pinches to zoom in the tiles are removed from the map and the custom tiles don't show up until the next level of tiles loads.
This behavior is different from MKMapKit and MapBox. They both scale custom tiles before the next level loads. Google maps does this for it's own base tiles. Any idea how to get the same behavior for custom tiles on Google maps iOS SDK?
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])
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 am using the Google Maps iOS SDK to draw a list of polylines. The polylines come from a server, and for each next polyline, the starting point corresponds with the end point of the previous polyline.
I notice that Google Maps changes the level of detail of the polylines at different zoom levels, probably an optimisation thing. This results in small gaps between the several polylines at lower zoom levels.
The reasons behind splitting a polyline up in several smaller lines are not up to me, this is what the system defines for me. I know I may be able to combine the several polylines into one single large polyline, but I was wondering: does the SDK allow the setting for this level of detail? Or is there maybe another fix?
Zoomed out, notice the gaps:
Almost fully-zoomed in, the gaps are nearly gone:
I have found no answer so far, so what I did, was traversing all geo-coordinates in-order (luckily my data-structure allows this), collect them in an array, encode this array to a Google Encoded Polyline (GEP) as per https://gist.github.com/mmdumi/3999640, and then display this on the map using [GMSPolyLine polylineWithPath:]. As far as I can tell, there is no way to instantiate a GMSPolyLine other than using a GEP.
I have found no answer too, but, there are two ways :
You can draw the entire line like a for sentence and draw, for example :
path.add(CLLocationCoordinate2D(latitude: latitude_,longitude: longitude_))
let polyline = GMSPolyline(path: path)
polyline.strokeColor = .red
polyline.map = mapView
polyline.strokeWidth = 2
or
https://github.com/raphaelmor/Polyline