【问题标题】:Add pin(not marker) to google map Android将图钉(不是标记)添加到谷歌地图 Android
【发布时间】:2016-02-22 22:13:19
【问题描述】:

如何在 android 中向谷歌地图添加图钉(不是标记)?
我知道如何添加标记,如下所示:

map.addMarker(new MarkerOptions()
                .position(new LatLng(lastLocation.getLatitude(), lastLocation.getLongitude()))
                .title(getString(R.string.start_location_marker)));



但我想要一个别针,而不是记号笔。
一个图钉看起来像这样:
pin

标记如下所示:
marker

【问题讨论】:

  • 将此行添加到标记.icon(BitmapDescriptorFactory.fromResource(R.drawable.pin)));..

标签: android google-maps google-maps-markers


【解决方案1】:

将您的 pin 图像设置为标记它称为自定义标记

@Override
public void onMapReady(GoogleMap googleMap) {

    BitmapDescriptor icon = BitmapDescriptorFactory.fromResource(R.drawable.pin);
    LatLng latLng = new LatLng(21.4225, 39.8262);
    googleMap.addMarker(new MarkerOptions().position(latLng).title("Mecca").icon(icon)).showInfoWindow();
    googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 15));
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-10-11
    • 2014-12-08
    • 2015-09-12
    • 1970-01-01
    • 2013-08-04
    • 2015-04-26
    • 1970-01-01
    相关资源
    最近更新 更多