Skip to content

Commit fb9da83

Browse files
authored
fix!: create bitmapdescriptor from asset on android (#347)
Breaking change due to changes in the native implementation for imgPath Release-As: 0.9.0
1 parent 3218cb1 commit fb9da83

File tree

7 files changed

+35
-8
lines changed

7 files changed

+35
-8
lines changed

android/src/main/java/com/google/android/react/navsdk/MapViewController.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public Marker addMarker(Map<String, Object> optionsMap) {
144144

145145
MarkerOptions options = new MarkerOptions();
146146
if (imagePath != null && !imagePath.isEmpty()) {
147-
BitmapDescriptor icon = BitmapDescriptorFactory.fromPath(imagePath);
147+
BitmapDescriptor icon = BitmapDescriptorFactory.fromAsset(imagePath);
148148
options.icon(icon);
149149
}
150150

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

291291
GroundOverlayOptions options = new GroundOverlayOptions();
292292
if (imagePath != null && !imagePath.isEmpty()) {
293-
BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromPath(imagePath);
293+
BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromAsset(imagePath);
294294
options.image(bitmapDescriptor);
295295
}
296296
options.position(new LatLng(lat, lng), width, height);

example/android/app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ react {
6565
// hermesFlags = ["-O", "-output-source-map"]
6666

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

7070
/* Autolinking */
7171
autolinkLibrariesWithApp()
680 Bytes
Loading
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"info" : {
3-
"version" : 1,
4-
"author" : "xcode"
3+
"author" : "xcode",
4+
"version" : 1
55
}
66
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"images" : [
3+
{
4+
"filename" : "circle.png",
5+
"idiom" : "universal",
6+
"scale" : "1x"
7+
},
8+
{
9+
"idiom" : "universal",
10+
"scale" : "2x"
11+
},
12+
{
13+
"idiom" : "universal",
14+
"scale" : "3x"
15+
}
16+
],
17+
"info" : {
18+
"author" : "xcode",
19+
"version" : 1
20+
}
21+
}
680 Bytes
Loading

example/src/controls/mapsControls.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ const MapsControls: React.FC<MapControlsProps> = ({ mapViewController }) => {
106106
console.log(result);
107107
};
108108

109-
const addMarker = async () => {
109+
const addMarker = async (imgPath?: string) => {
110110
const cameraPosition = await mapViewController.getCameraPosition();
111111

112112
const marker: Marker = await mapViewController.addMarker({
@@ -115,14 +115,19 @@ const MapsControls: React.FC<MapControlsProps> = ({ mapViewController }) => {
115115
title: 'Marker test',
116116
snippet: 'Marker test',
117117
alpha: 0.8,
118-
rotation: 20,
118+
rotation: 0,
119119
flat: false,
120120
draggable: true,
121+
imgPath: imgPath,
121122
});
122123

123124
console.log(marker);
124125
};
125126

127+
const addCustomMarker = async () => {
128+
addMarker('circle.png');
129+
};
130+
126131
const addCircle = async () => {
127132
const cameraPosition = await mapViewController.getCameraPosition();
128133

@@ -221,7 +226,8 @@ const MapsControls: React.FC<MapControlsProps> = ({ mapViewController }) => {
221226
setZoom((zoom ?? defaultZoom) - 1);
222227
}}
223228
/>
224-
<Button title="Add marker" onPress={addMarker} />
229+
<Button title="Add marker" onPress={() => addMarker()} />
230+
<Button title="Add custom marker" onPress={() => addCustomMarker()} />
225231
<Button title="Add circle" onPress={addCircle} />
226232
<Button title="Add polyline" onPress={addPolyline} />
227233
<Button title="Add polygon" onPress={addPolygon} />

0 commit comments

Comments
 (0)