/**
* Loads a marker icon via URL and places it on the map at the required position.
*
* @param googleMap
* @param latLng
* @param uri
*/
private void markerWithCustomIcon(final GoogleMap googleMap, final LatLng latLng, Uri uri, final String publicId) {
try {
Target target = new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
MarkerOptions options = new MarkerOptions();
options.position(latLng)
.icon(BitmapDescriptorFactory.fromBitmap(bitmap));
Marker marker = googleMap.addMarker(options);
publicMarkerIds.put(marker.getId(), publicId);
protectedFromGarbageCollectorTargets.remove(this);
}
@Override
public void onBitmapFailed(Drawable errorDrawable) {
System.out.println("Failed to load bitmap");
protectedFromGarbageCollectorTargets.remove(this);
}
@Override
public void onPrepareLoad(Drawable placeHolderDrawable) {
System.out.println("Preparing to load bitmap");
}
};
protectedFromGarbageCollectorTargets.add(target);
Picasso.with(reactContext)
.load(uri)
.into(target);
} catch (Exception ex) {
System.out.println(ex.getMessage());
markerWithDefaultIcon(googleMap,latLng, publicId);
}
}
PPTGoogleMapManager.java 文件源码
java
阅读 26
收藏 0
点赞 0
评论 0
项目:react-native-maps
作者:
评论列表
文章目录