【问题标题】:How to create minimalistic map for ios app如何为 ios 应用程序创建简约地图
【发布时间】:2019-04-09 09:27:42
【问题描述】:

如何实现与屏幕截图相同的地图?

我发现了 MKMapView 的自定义叠加层,但我不确定这是更改所有地图的好方法。

您可能对此有一些想法?

【问题讨论】:

    标签: ios swift google-maps mapkit mkmapview


    【解决方案1】:

    我不知道是否有更好的解决方案来实现这一点。 正如您在问题中提到的那样,我正在使用叠加层。

    您可以在https://mapstyle.withgoogle.com/https://mapstyle.withgoogle.com/ 以自己的美丽风格自定义叠加层

    您将获得用于自定义的 JSON,包括您的应用密钥,然后您就可以在您的应用中使用了。

    在您的应用中

    import GoogleMaps
    
    @IBOutlet weak var viewMap: GMSMapView!
    public let kMapStyle = "[{\"elementType\": \"geometry\", \"stylers\": [ { \"color\": \"#f5f5f5\" } ] },{\"elementType\": \"labels.icon\",\"stylers\": [{\"visibility\": \"on\"}]},{\"elementType\": \"labels.text.fill\",\"stylers\": [{\"color\": \"#616161\"}]},{\"elementType\": \"labels.text.stroke\",\"stylers\": [{\"color\": \"#f5f5f5\"}]},{\"featureType\": \"administrative.land_parcel\",\"elementType\": \"labels.text.fill\",\"stylers\": [{\"color\": \"#bdbdbd\"}]},{\"featureType\": \"poi\",\"elementType\": \"geometry\",\"stylers\": [{\"color\": \"#eeeeee\"}]},{\"featureType\": \"poi\",\"featureType\":\"poi.business\",\"stylers\": [{\"visibility\": \"on\"}],\"elementType\": \"labels.text.fill\",\"stylers\": [{\"color\": \"#757575\"}]},{\"featureType\": \"poi.park\",\"elementType\": \"geometry\",\"stylers\": [{\"color\": \"#e5e5e5\"}]},{\"featureType\": \"poi.park\",\"elementType\": \"labels.text.fill\",\"stylers\": [{\"color\": \"#9e9e9e\"}]},{\"featureType\": \"road\",\"elementType\": \"geometry\",\"stylers\": [{\"color\": \"#ffffff\"}]},{\"featureType\": \"road.arterial\",\"elementType\": \"labels.text.fill\",\"stylers\": [{\"color\": \"#757575\"}]},{\"featureType\": \"road.highway\",\"elementType\": \"geometry\",\"stylers\": [{\"color\": \"#dadada\"}]},{\"featureType\": \"road.highway\",\"elementType\": \"labels.text.fill\",\"stylers\": [{\"color\": \"#616161\"}]},{\"featureType\": \"road.local\",\"elementType\": \"labels.text.fill\",\"stylers\": [{\"color\": \"#9e9e9e\"}]},{\"featureType\": \"transit.line\",\"elementType\": \"geometry\",\"stylers\": [{\"color\": \"#e5e5e5\"}]},{\"featureType\": \"transit.station\",\"elementType\": \"geometry\",\"stylers\": [{\"color\": \"#eeeeee\"}]},{\"featureType\": \"water\",\"elementType\": \"geometry\",\"stylers\": [{\"color\": \"#c9c9c9\"}]},{\"featureType\": \"water\",\"elementType\": \"labels.text.fill\",\"stylers\": [{\"color\": \"#9e9e9e\"}]}]"
    //YOUR JSON FOR STYLE
    
    override func viewDidLoad() {
        super.viewDidLoad()
        do {
            viewMap.mapStyle = try GMSMapStyle(jsonString: kMapStyle)
        } catch {
            NSLog("One or more of the map styles failed to load. \(error)")
        }
    }
    

    如果这有帮助,或者您在实施过程中遇到任何其他问题,请告诉我。

    【讨论】:

      猜你喜欢
      • 2013-04-11
      • 2012-02-11
      • 1970-01-01
      • 2020-01-18
      • 1970-01-01
      • 2014-12-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多