简体   繁体   English

在Google Map Android上添加图标和标记

[英]Add icons and marker on Google Map Android

Is there anyway to add Popup view (car icon,duration and distance) like the image below in android ?I have used marker to indicate locations .When user click location , I would like to show Popup view with icons,duration,distance. 无论如何有没有像下面的图像一样在Android中添加Popup视图(汽车图标,持续时间和距离)?我使用了标记来指示位置。当用户单击location时,我想显示带有图标,持续时间,距离的Popup视图。

// Creating an instance of MarkerOptions
MarkerOptions markerOptions = new MarkerOptions();

// Setting latitude and longitude for the marker
markerOptions.position(point);
markerOptions.title(clientName);

if(bitmap != null)
{ markerOptions.icon(BitmapDescriptorFactory.fromBitmap(bitmap));}
else{
    markerOptions.icon(BitmapDescriptorFactory.defaultMarker());
}

// Adding marker on the Google Map
googleMap.addMarker(markerOptions);

在此输入图像描述

This page explains the Marker object from Google Maps Android API. 本页说明了Google Maps Android API中的Marker对象。 I think there is some usefull info for you in there. 我认为那里有一些有用的信息。 https://developers.google.com/maps/documentation/android-api/marker https://developers.google.com/maps/documentation/android-api/marker

Hope this will put you on track: 希望这能使您步入正轨:

private MapFragment mMapFragment;
//(in my case, MapFragment extends SupportMapFragment implements GoogleMap.OnInfoWindowClickListener)
Marker marker =  mMapFragment.addMarker(
                    new MarkerOptions()
                            .position(new LatLng(Double.parseDouble(yourObject.getLatitude()), Double.parseDouble(yourObject.getLongitude())))
                            .title(yourObject.getName())
                            .snippet(yourObject.getAddress())
                            .data(yourObject.getWhatever()), yourObject);
            mAddedObjectsIds.put(yourObject.getId(),marker);

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

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