Reputation: 4384
I am new to android map view. I have to display different color in android map view based on rainfall on particular area. Please help me to figure out this functionality.
Your help would be highly appreciated.
Upvotes: 1
Views: 1123
Reputation: 1934
Well in the old API also, you can show color on the map, by making the overlays of your customized shapes like circle, rectangle or anything.
Just override draw()
in your Overlay
class.
Having new API is always good, but its ok to use anyone for now.
This page tries to explain how to construct an overlay with custom shape and color.
Hope this will help.
Upvotes: 2
Reputation: 17115
Make sure to use Map API v2 instead of the old API's (not all people aware it's out). You can always get the updated visible region when user scrolls by setting onCameraChangeListener to your GoogleMap.
googleMap.setOnCameraChangeListener(new GoogleMap.OnCameraChangeListener()
{
@Override
public void onCameraChange(CameraPosition arg0)
{
VisibleRegion r = googleMap.getProjection().getVisibleRegion();
}
});
Make your layout something like
<fragment
class="com.google.android.gms.maps.SupportMapFragment"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="@+id/map_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
map:cameraZoom="14"/>
<yout.package.view.ColorOverlay
android:id="@+id/overlay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#00000000"/>
Add a fullscreen map fragment, and an overlay with transparent background which will draw your color zones. The idea is to make yout custom View that will draw the colors based on VisibleRegion's northeast and southwest LatLng points and their's position on screen and make it draw above the map. That's the hardest work :)
Upvotes: 2