From 5b045ca748a78d20cf7bda187492f57680bd39ca Mon Sep 17 00:00:00 2001 From: bsudekum Date: Fri, 18 Dec 2015 10:33:11 -0800 Subject: [PATCH] Send context through --- .../reactnativemapboxgl/ReactNativeMapboxGLManager.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/android/src/main/java/com/mapbox/reactnativemapboxgl/ReactNativeMapboxGLManager.java b/android/src/main/java/com/mapbox/reactnativemapboxgl/ReactNativeMapboxGLManager.java index 080325d..13747fd 100644 --- a/android/src/main/java/com/mapbox/reactnativemapboxgl/ReactNativeMapboxGLManager.java +++ b/android/src/main/java/com/mapbox/reactnativemapboxgl/ReactNativeMapboxGLManager.java @@ -93,7 +93,7 @@ public class ReactNativeMapboxGLManager extends SimpleViewManager { mapView.setTilt(pitch, 1L); } - public static Drawable drawableFromUrl(String url) throws IOException { + public static Drawable drawableFromUrl(MapView view, String url) throws IOException { Bitmap x; HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection(); @@ -101,7 +101,7 @@ public class ReactNativeMapboxGLManager extends SimpleViewManager { InputStream input = connection.getInputStream(); x = BitmapFactory.decodeStream(input); - return new BitmapDrawable(x); + return new BitmapDrawable(view.getResources(), x); } @ReactProp(name = PROP_ANNOTATIONS) @@ -131,8 +131,7 @@ public class ReactNativeMapboxGLManager extends SimpleViewManager { ReadableMap annotationImage = annotation.getMap("annotationImage"); String annotationURL = annotationImage.getString("url"); try { - Drawable image = drawableFromUrl(annotationURL); - image.setBounds(0, 0, 100, 100); + Drawable image = drawableFromUrl(mapView, annotationURL); SpriteFactory spriteFactory = view.getSpriteFactory(); Sprite icon = spriteFactory.fromDrawable(image); marker.icon(icon);