答案 0 :(得分:5)
您可以按照自己的方式自定义地图:https://mapstyle.withgoogle.com/
完成自定义后,复制json并将项目添加到文件中 style.json
然后将此样式指定给地图:
do {
// Set the map style by passing the URL of the local file.
if let styleURL = Bundle.main.url(forResource: "style", withExtension: "json") {
mapView.mapStyle = try GMSMapStyle(contentsOfFileURL: styleURL)
} else {
NSLog("Unable to find style.json")
}
} catch {
NSLog("One or more of the map styles failed to load. \(error)")
}
答案 1 :(得分:0)
您必须使用custom tiles:
x
磁贴可以来自具有http请求的服务器,也可以来自捆绑包。
基本上,图块是在z
- zoom
上显示一张地图的图片,其中let layer = TestTileLayer()
layer.map = mapView
。
用法:
scene.setOnMouseMoved(e -> {
int screenWidth = (int) Screen.getPrimary().getBounds().getWidth();
int screenHeight = (int) Screen.getPrimary().getBounds().getHeight();
moveCursor(screenWidth / 2, screenHeight / 2);
double dx = mouseX - e.getSceneX();
double dy = mouseY - e.getSceneY();
mouseX = e.getSceneX();
mouseY = e.getSceneY();
camAngleX += dx / 10;
camAngleY -= dy / 10;
});
答案 2 :(得分:-1)
设置地图样式的最佳方法:
1.Select Your Style From Here:
[https://mapstyle.withgoogle.com][1]
2.Add JSON File To Your Project
3.Add This Function :
func mapStyle(withFilename name: String, andType type: String) {
do {
if let styleURL = Bundle.main.url(forResource: name, withExtension: type) {
self.mapStyle = try GMSMapStyle(contentsOfFileURL: styleURL)
}else {
NSLog("Unable to find darkMap")
}
}
catch {
NSLog("failded to load. \(error)")
}
}
如何使用它:
self.mapView.mapStyle(withFilename: "darkMap", andType: "json")