Google 地图如何在自定义地点显示我的位置标记?
Google Maps how to display my location marker in the custom place?
我想在自定义位置显示“我的位置”标记(蓝色圆一),因为我可以选择 select 我在地图上的位置,而不是使用 GPS/Wifi/GSM 中的位置,是否可以使用 Android 上现有的 Google 地图 API?或者以某种方式提取资产并将其显示为 MapView 中的自定义标记?
我最终用这样的 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 更改它或不支持开箱即用的夜间模式,它就会过时,但对我和现在来说,它是有效的。我愿意接受任何更好的解决方案。
我想在自定义位置显示“我的位置”标记(蓝色圆一),因为我可以选择 select 我在地图上的位置,而不是使用 GPS/Wifi/GSM 中的位置,是否可以使用 Android 上现有的 Google 地图 API?或者以某种方式提取资产并将其显示为 MapView 中的自定义标记?
我最终用这样的 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 更改它或不支持开箱即用的夜间模式,它就会过时,但对我和现在来说,它是有效的。我愿意接受任何更好的解决方案。