Skip to content

Commit

Permalink
fix!: create bitmapdescriptor from asset on android (#347)
Browse files Browse the repository at this point in the history
Breaking change due to changes in the native implementation for imgPath
Release-As: 0.9.0
  • Loading branch information
jokerttu authored Nov 20, 2024
1 parent 3218cb1 commit fb9da83
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public Marker addMarker(Map<String, Object> optionsMap) {

MarkerOptions options = new MarkerOptions();
if (imagePath != null && !imagePath.isEmpty()) {
BitmapDescriptor icon = BitmapDescriptorFactory.fromPath(imagePath);
BitmapDescriptor icon = BitmapDescriptorFactory.fromAsset(imagePath);
options.icon(icon);
}

Expand Down Expand Up @@ -290,7 +290,7 @@ public GroundOverlay addGroundOverlay(Map<String, Object> map) {

GroundOverlayOptions options = new GroundOverlayOptions();
if (imagePath != null && !imagePath.isEmpty()) {
BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromPath(imagePath);
BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromAsset(imagePath);
options.image(bitmapDescriptor);
}
options.position(new LatLng(lat, lng), width, height);
Expand Down
2 changes: 1 addition & 1 deletion example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ react {
// hermesFlags = ["-O", "-output-source-map"]

/* This example app uses typescript index file, so we need to specify the entry file */
entryFile = file("index.ts")
entryFile = file("../../index.ts")

/* Autolinking */
autolinkLibrariesWithApp()
Expand Down
Binary file added example/android/app/src/main/assets/circle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions example/ios/SampleApp/Images.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "circle.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 9 additions & 3 deletions example/src/controls/mapsControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const MapsControls: React.FC<MapControlsProps> = ({ mapViewController }) => {
console.log(result);
};

const addMarker = async () => {
const addMarker = async (imgPath?: string) => {
const cameraPosition = await mapViewController.getCameraPosition();

const marker: Marker = await mapViewController.addMarker({
Expand All @@ -115,14 +115,19 @@ const MapsControls: React.FC<MapControlsProps> = ({ mapViewController }) => {
title: 'Marker test',
snippet: 'Marker test',
alpha: 0.8,
rotation: 20,
rotation: 0,
flat: false,
draggable: true,
imgPath: imgPath,
});

console.log(marker);
};

const addCustomMarker = async () => {
addMarker('circle.png');
};

const addCircle = async () => {
const cameraPosition = await mapViewController.getCameraPosition();

Expand Down Expand Up @@ -221,7 +226,8 @@ const MapsControls: React.FC<MapControlsProps> = ({ mapViewController }) => {
setZoom((zoom ?? defaultZoom) - 1);
}}
/>
<Button title="Add marker" onPress={addMarker} />
<Button title="Add marker" onPress={() => addMarker()} />
<Button title="Add custom marker" onPress={() => addCustomMarker()} />
<Button title="Add circle" onPress={addCircle} />
<Button title="Add polyline" onPress={addPolyline} />
<Button title="Add polygon" onPress={addPolygon} />
Expand Down

0 comments on commit fb9da83

Please sign in to comment.