Google Maps Android API v2: My location marker always over other markers?

后端 未结 1 1426
逝去的感伤
逝去的感伤 2020-12-30 16:44

Currently migrating an Android app using Google Maps to Google Maps Android v2; I want the map to display the built-in location marker, as well as custom markers. With the

相关标签:
1条回答
  • 2020-12-30 17:22

    After a bit a searching, I couldn't find such an option.

    I finally removed the location pin, and added a similar Marker and Circle to the map; since it is a classic Marker, it appears below the other markers.

    map.setMyLocationEnabled(false);
    
    // ...
    // get the current location with Android LocationManager in some way
    // ...
    
    // then draw it on the map when it changes:
    if (null == getMyLocation())
        return;
    
    if (null != locationMarker) {
        locationMarker.remove();
    }
    if (null != locationCircle) {
        locationCircle.remove();
    }
    LatLng loc = getMyLocation();
    
    locationMarker = map.addMarker(new MarkerOptions()
            .icon(BitmapDescriptorFactory
                    .fromResource(R.drawable.blue_pin_12))
            .position(getMyLocation()).anchor(0.5f, 0.5f));
    
    float accuracy = getMyLocationAccuracy();
    
    locationCircle = map.addCircle(new CircleOptions().center(loc)
                .radius(accuracy)
                .strokeColor(Color.argb(255, 0, 153, 255))
                .fillColor(Color.argb(30, 0, 153, 255)).strokeWidth(2));
    

    Location pin

    0 讨论(0)
提交回复
热议问题