Reputation: 12169
The web version of Google maps allows the developer to show a map legend that indicates the map's scale.
Is there any way to do this using the Android API?
Additional info:
Upvotes: 2
Views: 6103
Reputation: 23873
Have a look at how they did for the very similar Osmdroid which is for OpenStreetMap
it should give some ideas. It's probably more fully featured than you need.
Upvotes: 3
Reputation: 64700
Create a layout with the text view, load it in your onCreate and then write the map scale into it using setText(). An example layout is below:
<?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>
In your activity, you can do
((TextView)findViewById(R.id.scale)).setText("<map scale>");
and it should appear on top of the map. You can style the text view however you want as well.
Upvotes: 1