简体   繁体   English

Google地图标记仅显示图标

[英]Google maps marker show only icon

I want to display markers on google maps (android) 我想在Google地图上显示标记(Android)

I used this code (like in the example in android developer): 我使用了以下代码(例如在android开发人员的示例中):

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? 另外, 示例代码是否与Google Play服务SDK捆绑在一起?

Edit : You can show an info window programmatically by calling showInfoWindow() on the target marker: 编辑 :您可以通过在目标标记上调用showInfoWindow()来以编程方式显示信息窗口:

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. 此代码适用于使用API​​ V2的Google地图。添加google的内置方法。

public void onMapLongClick(LatLng point) { 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));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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