How to replace blue dot with my icon on google maps v2 in android?

半世苍凉 提交于 2019-12-19 08:55:37

问题


I am trying to replace blue dot (which shown current location on maps) with my own icon on Google maps v2. I have tried below, none worked.

  • Android Maps API v2 Change MyLocation Icon
  • Maps V2 myLocation blue dot callback
  • Disable center button in MyLocation at Google Map API V2

Should look like this

Below did not work

Bitmap b = BitmapFactory.decodeResource(getResources(),
        R.drawable.location_arrow1);
googleMap.addMarker(new MarkerOptions().position(myPosition)
        .title(getIntent().getStringExtra("first_name"))
        .icon(BitmapDescriptorFactory.fromBitmap(b)));

回答1:


You will have to stop using GoogleMap.setMyLocationEnabled and write a bit more code, including receiving location updates on your own and adding Circle for accuracy.




回答2:


I think you pass your current location to LocationSource to be able to use the my-location button.

You have to do that on your own. - set to false gmaps.getUiSettings().setMyLocationButtonEnabled(false);

  • create your own location button
  • if you get your current location, set a marker with your icon on that
  • if you click on your location button, move the camera and center it to the map


来源:https://stackoverflow.com/questions/16855878/how-to-replace-blue-dot-with-my-icon-on-google-maps-v2-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!