Google地图的网络版允许开发者显示指示地图比例尺的地图图例。如何在Android Google Map上显示地图图例?
有什么办法可以使用Android API来做到这一点?
附加信息:喜欢你,如果你去谷歌地图
- 我想显示的图形“这距离等于X米”之类的显示。
- 应该可以使用:getProjection(),但我只是希望有一种方法来启用图例。
- 如果您打开Google地图应用并选择“实验室”,您可以启用我想要的“比例尺”。
Google地图的网络版允许开发者显示指示地图比例尺的地图图例。如何在Android Google Map上显示地图图例?
有什么办法可以使用Android API来做到这一点?
附加信息:喜欢你,如果你去谷歌地图
使用文本视图创建布局,将其加载到您的onCreate中,然后使用setText()将地图比例写入它。一个例子布局如下:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:id="@+id/root">
<com.google.android.maps.MapView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:enabled="true"
android:clickable="true"
android:id="@+id/map"
android:apiKey="<YOUR KEY>"
android:layout_alignParentTop="true" android:layout_alignParentRight="true" android:layout_alignParentL
eft="true" android:layout_alignParentBottom="true"/>
<TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_alignParentTop="true" android:layout_alignParentLeft="true" android:layout_alignParentRight="true" android:layout_marginLeft="10sp" android:layout_marginRight="10sp" android:layout_marginTop="10sp" android:id="@+id/scale" android:gravity="center_horizontal"></TextView>
</RelativeLayout>
在你的活动中,你可以做
((TextView)findViewById(R.id.scale)).setText("<map scale>");
,它应该会出现在地图上。不过,您也可以设置文本视图的样式。
这不回答我的问题。查看其他信息的问题 – gregm 2011-04-25 21:23:21
我想你将不得不像你说的那样使用getProjection。在屏幕的左侧和右侧找到GeoPoints,在它们之间求出km,选择合适的1km/10km(取决于缩放)等等线,在画布上绘制一些文字并将其添加为覆盖图。也许添加一些细分刻度标记。非常乏味,但它完成后应该看起来不错! – NickT 2011-04-25 21:31:39