【问题标题】:Google Maps how to display my location marker in the custom place?谷歌地图如何在自定义地点显示我的位置标记?
【发布时间】:2021-01-17 06:52:22
【问题描述】:

我想在自定义位置显示“我的位置”(蓝色圆形第一)的标记,因为我可以选择从地图中选择我的位置,而不是使用 GPS/Wifi/GSM 中的位置,是否可以这样做Android 上现有的 Google Maps API?或者也许以某种方式提取资产并将其显示为 MapView 中的自定义标记?

【问题讨论】:

    标签: android google-maps-markers google-maps-android-api-2 android-maps-v2


    【解决方案1】:

    我最终用这样的 XML 实现了自定义标记,它看起来与 Google 地图中的标记相同:

    <?xml version="1.0" encoding="UTF-8"?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
      <item>
        <shape android:shape="oval">
          <solid android:color="@color/map_my_location_inner" />
        </shape>
      </item>
      <item
          android:bottom="0.5dp"
          android:left="0.5dp"
          android:right="0.5dp"
          android:top="0.5dp">
        <shape android:shape="oval">
          <solid android:color="@color/map_my_location_outer" />
        </shape>
      </item>
      <item
          android:bottom="2dp"
          android:left="2dp"
          android:right="2dp"
          android:top="2dp">
        <shape android:shape="oval">
          <solid android:color="@color/map_my_location_inner" />
        </shape>
      </item>
    </layer-list>
    

    它并不完美,因为一旦 Google 更改它或不支持开箱即用的夜间模式,它就会过时,但对我来说,现在它可以工作。我愿意接受任何更好的解决方案。

    【讨论】:

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