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:
Clément Beffa
2016-05-06 14:14:30 -07:00
committed by Bobby Sudekum
parent 4128db9b29
commit 3124f5e8cd
@@ -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();