Map Markers with text in Google Maps Android API v2

后端 未结 6 1215
难免孤独
难免孤独 2020-11-30 05:19

I have came up with this post but it is for the deprecated Google Maps API

http://tech.truliablog.com/2012/02/23/custom-map-markers-for-android-google-maps/

6条回答
  •  一个人的身影
    2020-11-30 05:44

    by referring to Google's sample code

    IconGenerator iconFactory = new IconGenerator(this);    
            iconFactory.setColor(Color.CYAN);
            addIcon(mMap, iconFactory, "Custom color", new LatLng(-33.9360, 151.2070));
    

    addIcon() Method here:

    private void addIcon(GoogleMap googleMap, IconGenerator iconFactory, CharSequence text, LatLng position) {
            MarkerOptions markerOptions = new MarkerOptions().
                    icon(BitmapDescriptorFactory.fromBitmap(iconFactory.makeIcon(text))).
                    position(position).
                    anchor(iconFactory.getAnchorU(), iconFactory.getAnchorV());
    
            googleMap.addMarker(markerOptions);
        }
    

提交回复
热议问题