0

I have a map on which I want to place the ImageView with its tip touching the equator.I gave the attribute centerVertical=true and centerHorizontal=true to the ImageView,but it is not positioned on the equator.I got the center of the map but I want the ImageView to be positioned on the equator of the map.

Screenshot:

enter image description here

Code:

@Override
    public void onMapReady(GoogleMap googleMap) {
        this.googleMap = googleMap;
        googleMap.getUiSettings().setZoomControlsEnabled(true);
        googleMap.getUiSettings().setCompassEnabled(true);
        //center of map
        LatLng centerOfMap=this.googleMap.getCameraPosition().target;
}

marker_view.xml:

    <?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" >
    <ImageView
        android:id="@+id/marker_icon_view"
        android:layout_width="30dp"
        android:layout_height="30dp"
        android:layout_centerVertical="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="162dp"
        android:contentDescription="@string/app_name"
        android:src="@drawable/marker" />
</RelativeLayout>
jobin
  • 1,489
  • 5
  • 27
  • 52

1 Answers1

0

You should use Markers. You can also customize them. Have a look at the following documents by Google and SO.

https://developers.google.com/maps/documentation/android-api/marker

How to create a custom-shaped bitmap marker with Android map API v2

Community
  • 1
  • 1
Ruchira Randana
  • 4,021
  • 1
  • 27
  • 24
  • I want the marker to be seen even when the user moves the map – jobin Oct 19 '16 at 07:38
  • Using Projection class I got the screen location of LatLng(0.0,0.0) of equator, but it shows x and y value as 0. – jobin Oct 19 '16 at 07:42
  • Just set double height to your `drawable/marker` and its center should be right on the bottom. And take a look at [this](http://stackoverflow.com/q/40112760/6950238) conversation. – Andrii Omelchenko Oct 19 '16 at 07:51