简体   繁体   中英

How to create a Location arrow Marker with Sensor bearing in Android Google Maps v2?

I have managed to create an arrow ImageView and get the azimuth from the sensors, after that I rotate the ImageView using setRotation() method of the View class. How I can do this for a marker using Android Google Maps v2 Markers?

I suggest you take a look at the android-maps-utils project from Google.

It contains

  • BubbleIconFactory : Responsible for generating markers
  • RotationLayout : Responsible for rotating the contents of the layout (the marker) by multiples of 90 degrees

This should give you the building blocks you need to display your arrow/marker and give it a certain rotation. You'll probably need to customize the rotationlayout a bit.

you can use: https://developers.google.com/maps/documentation/android/marker#rotate_a_marker

com.google.android.gms.maps.model.Marker marker = addMapMarker(camera,PrefManager.getCurrentUsername(getActivity()),
            BitmapDescriptorFactory.fromResource(R.drawable.overlay_gps_location_scanner_icon));
marker.setRotation(0);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM