【问题标题】:Hide street names in Google Maps API在 Google Maps API 中隐藏街道名称
【发布时间】:2015-07-13 09:16:05
【问题描述】:

我正在尝试使用地图进行游戏。我需要一张没有街道名称的地图。是否可以在 Google Maps API(iOS、Android)中隐藏街道名称(但不能隐藏其值)?

【问题讨论】:

    标签: google-maps google-maps-android-api-2 google-maps-sdk-ios


    【解决方案1】:

    在res/raw中创建一个json文件,例如style_json.txt

    在文件中,输入:

    [
      {
        "featureType": "poi",
        "stylers": [
          { "visibility": "off" }
        ]
      }
    ]
    

    然后在你的 onMapReady 中:

        @Override
        public void onMapReady(GoogleMap googleMap) {
            //your code
            try {
               boolean success = googleMap.setMapStyle(MapStyleOptions.loadRawResourceStyle(
                                this, R.raw.style_json));
    
                if (!success) {
                    Log.e(TAG, "Style parsing failed.");
                }
            } catch (Resources.NotFoundException e) {
                Log.e(TAG, "Can't find style. Error: ", e);
            }
            //your code
        }
    

    来源:https://developers.google.com/maps/documentation/android-api/poi 和:https://developers.google.com/maps/documentation/android-api/hiding-features

    【讨论】:

    • @BaummitAugen 更好吗?
    • 现在看起来好多了,谢谢。 (顺便说一句,不是我的反对意见,我缺乏对此进行投票的领域知识。)
    【解决方案2】:

    您需要样式。您只需要关闭所有标签的可见性。但是,据我所知,Google Maps iOS 或 Android API 尚无法设置地图样式。

    您可以通过静态地图和 JavaScript API 来实现。

    这是一个关于如何使用静态地图的示例。 http://maps.googleapis.com/maps/api/staticmap?center=37.420988,-122.086891&zoom=17&format=png&sensor=false&size=640x480&maptype=roadmap&style=element:labels|visibility:off

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多