Android Maps API v2 Change MyLocation Icon

后端 未结 6 1709
野趣味
野趣味 2020-11-27 04:50

I would like to replace the default icon that Android Maps V2 uses for \'My Location\' (The little blue dot/arrow) with my own image. I\'ve created my own tile provide

6条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-27 05:34

    my simple solution way is just disable "my location" of Google map

    and create ImageView on Map with my icon then capture ImageView with

    onClick and getMyLocation , animateCamera in onClick

     this.mGoogleMap.getUiSettings().setMyLocationButtonEnabled(false);
     this.mGoogleMap.setMyLocationEnabled(true);
    

    .

    @Override
    public void onClick(final View v) {
    
        Location location = this.mGoogleMap.getMyLocation();
    
            if (location != null) {
    
                LatLng target = new LatLng(location.getLatitude(), location.getLongitude());
                CameraPosition position = this.mGoogleMap.getCameraPosition();
    
                Builder builder = new CameraPosition.Builder();
                builder.zoom(15);
                builder.target(target);
    
                this.mGoogleMap.animateCamera(CameraUpdateFactory.newCameraPosition(builder.build()));
    
              }    
    }
    

提交回复
热议问题