Use bitmap instead of drawable
This commit is contained in:
parent
40b743aeb0
commit
803d009a54
2 changed files with 15 additions and 4 deletions
|
@ -341,7 +341,8 @@ public class MainActivity extends AppCompatActivity implements SampleLocationLis
|
||||||
public void initMapMarkers() {
|
public void initMapMarkers() {
|
||||||
|
|
||||||
// Create my location marker
|
// Create my location marker
|
||||||
Drawable myLocationDrawable = OsmandResources.getDrawable("map_pedestrian_location");
|
String locIconId = "map_pedestrian_location";
|
||||||
|
Drawable myLocationDrawable = OsmandResources.getDrawable(locIconId);
|
||||||
myMarkersCollection = new MapMarkersCollection();
|
myMarkersCollection = new MapMarkersCollection();
|
||||||
myLocationMarker = new MapMarkerBuilder()
|
myLocationMarker = new MapMarkerBuilder()
|
||||||
.setMarkerId(MARKER_ID_MY_LOCATION)
|
.setMarkerId(MARKER_ID_MY_LOCATION)
|
||||||
|
@ -354,13 +355,14 @@ public class MainActivity extends AppCompatActivity implements SampleLocationLis
|
||||||
// SampleUtils.getDrawableAsByteArray(myLocationDrawable)))
|
// SampleUtils.getDrawableAsByteArray(myLocationDrawable)))
|
||||||
.setPinIcon(SwigUtilities.createSkBitmapARGB888With(
|
.setPinIcon(SwigUtilities.createSkBitmapARGB888With(
|
||||||
myLocationDrawable.getIntrinsicWidth(), myLocationDrawable.getIntrinsicHeight(),
|
myLocationDrawable.getIntrinsicWidth(), myLocationDrawable.getIntrinsicHeight(),
|
||||||
SampleUtils.getDrawableAsByteArray(myLocationDrawable)))
|
SampleUtils.getBitmapAsByteArray(OsmandResources.getBitmap(locIconId))))
|
||||||
.buildAndAddToCollection(myMarkersCollection);
|
.buildAndAddToCollection(myMarkersCollection);
|
||||||
|
|
||||||
mapView.addSymbolsProvider(myMarkersCollection);
|
mapView.addSymbolsProvider(myMarkersCollection);
|
||||||
|
|
||||||
// Create context pin marker
|
// Create context pin marker
|
||||||
Drawable pinDrawable = OsmandResources.getDrawable("map_pin_context_menu");
|
String pinIconId = "map_pin_context_menu";
|
||||||
|
Drawable pinDrawable = OsmandResources.getDrawable(pinIconId);
|
||||||
contextPinMarkersCollection = new MapMarkersCollection();
|
contextPinMarkersCollection = new MapMarkersCollection();
|
||||||
contextPinMarker = new MapMarkerBuilder()
|
contextPinMarker = new MapMarkerBuilder()
|
||||||
.setMarkerId(MARKER_ID_CONTEXT_PIN)
|
.setMarkerId(MARKER_ID_CONTEXT_PIN)
|
||||||
|
@ -369,7 +371,7 @@ public class MainActivity extends AppCompatActivity implements SampleLocationLis
|
||||||
.setIsHidden(true)
|
.setIsHidden(true)
|
||||||
.setPinIcon(SwigUtilities.createSkBitmapARGB888With(
|
.setPinIcon(SwigUtilities.createSkBitmapARGB888With(
|
||||||
pinDrawable.getIntrinsicWidth(), pinDrawable.getIntrinsicHeight(),
|
pinDrawable.getIntrinsicWidth(), pinDrawable.getIntrinsicHeight(),
|
||||||
SampleUtils.getDrawableAsByteArray(pinDrawable)))
|
SampleUtils.getBitmapAsByteArray(OsmandResources.getBitmap(pinIconId))))
|
||||||
.setPinIconVerticalAlignment(MapMarker.PinIconVerticalAlignment.Top)
|
.setPinIconVerticalAlignment(MapMarker.PinIconVerticalAlignment.Top)
|
||||||
.setPinIconHorisontalAlignment(MapMarker.PinIconHorisontalAlignment.CenterHorizontal)
|
.setPinIconHorisontalAlignment(MapMarker.PinIconHorisontalAlignment.CenterHorizontal)
|
||||||
.buildAndAddToCollection(contextPinMarkersCollection);
|
.buildAndAddToCollection(contextPinMarkersCollection);
|
||||||
|
|
|
@ -3,6 +3,8 @@ package net.osmand.core.samples.android.sample1;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.support.v4.graphics.drawable.DrawableCompat;
|
import android.support.v4.graphics.drawable.DrawableCompat;
|
||||||
|
|
||||||
|
@ -78,6 +80,13 @@ public class OsmandResources {
|
||||||
return getDrawableInternal(id);
|
return getDrawableInternal(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Bitmap getBitmap(String id) {
|
||||||
|
if (osmandResources != null) {
|
||||||
|
return BitmapFactory.decodeResource(osmandResources, resolveDrawableId(id));
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public static Drawable getDrawableNonCached(int id) {
|
public static Drawable getDrawableNonCached(int id) {
|
||||||
if (osmandResources != null && id != 0) {
|
if (osmandResources != null && id != 0) {
|
||||||
Drawable d = osmandResources.getDrawable(id);
|
Drawable d = osmandResources.getDrawable(id);
|
||||||
|
|
Loading…
Reference in a new issue