mirror of
https://github.com/status-im/react-native-mapbox-gl.git
synced 2026-08-31 04:51:15 +00:00
Add height and width support to annotationImage (android) (#337)
* Add height and width support to annotationImage (android) Depending on device scale like on ios * use scale var
This commit is contained in:
committed by
Bobby Sudekum
parent
4128db9b29
commit
3124f5e8cd
+9
-1
@@ -153,7 +153,15 @@ public class ReactNativeMapboxGLManager extends SimpleViewManager<MapView> {
|
||||
image = drawableFromUrl(mapView, annotationURL);
|
||||
}
|
||||
IconFactory iconFactory = view.getIconFactory();
|
||||
Icon icon = iconFactory.fromDrawable(image);
|
||||
Icon icon;
|
||||
if (annotationImage.hasKey("height") && annotationImage.hasKey("width")) {
|
||||
float scale = view.getResources().getDisplayMetrics().density;
|
||||
int height = Math.round((float)annotationImage.getInt("height") * scale);
|
||||
int width = Math.round((float)annotationImage.getInt("width") * scale);
|
||||
icon = iconFactory.fromDrawable(image, width, height);
|
||||
} else {
|
||||
icon = iconFactory.fromDrawable(image);
|
||||
}
|
||||
marker.icon(icon);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
||||
Reference in New Issue
Block a user