简体   繁体   中英

Google maps marker show only icon

I want to display markers on google maps (android)

I used this code (like in the example in android developer):

The location, name and descripion are valid (I checked them via debug mode)

It shows me the icon on the desired location, however without the marker or the description and snippets. The following line

mMap.addMarker(MarkerOptions().position(location)
    .title(poi.getName()).snippet(poi.getDescription())
    .icon(BitmapDescriptorFactory.fromBitmap(image_item));

shows me only the icon without the title or snippest.

Thanks a lot

Did you follow the examples from the documentation ? Also, the sample code bundled with the Google Play services SDK?

Edit : You can show an info window programmatically by calling showInfoWindow() on the target marker:

Marker marker = mMap.addMarker(new MarkerOptions()
                      .position(location)
                      .title(poi.getName())
                      .snippet(poi.getDescription())
                      .icon(BitmapDescriptorFactory.fromBitmap(image_item));
marker.showInfoWindow();

However, bear in mind that only one info window can be displayed at a time. If a user clicks on another marker, the current window will be hidden and the new info window will be displayed.

try this code. This code is work on Google map with API V2 Add the inbuilt method of google.

public void onMapLongClick(LatLng point) {

    // Getting the Latitude and Longitude of the touched location
    latLng = point;
    // Clears the previously touched position
    myMap.clear();
    // Animating to the touched position
    myMap.animateCamera(CameraUpdateFactory.newLatLng(latLng));
    // Creating a marker
    markerOptions = new MarkerOptions();
    // Setting the position for the marker
    markerOptions.position(latLng);
    // Adding Marker on the touched location with address

    new ReverseGeocodingTask(getBaseContext()).execute(latLng);
    tmpLatLng = latLng;
    drawCircle(point);
    btLocInfo.setEnabled(true);
}

这不是一个罕见的问题,修复它的唯一方法是重新安装它唯一能够修复它的方法。

show icon without the title or snippest. use below code

LatLng newYork = new LatLng(40.7142, 74.0064);
Marker melbourne = map.addMarker(new MarkerOptions()
                    .position(newYork));

Edited:

show marker with title & Snippest & icon

map.addMarker(new MarkerOptions().position(new LatLng(lat, lon))
                .title(string).snippet(string2).icon(BitmapDescriptorFactory.fromBitmap(image_item));

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