From fb9da83b03fa8cd57c89fe917bd351dbf8c1a4d9 Mon Sep 17 00:00:00 2001 From: Joonas Kerttula Date: Wed, 20 Nov 2024 12:28:47 +0200 Subject: [PATCH] fix!: create bitmapdescriptor from asset on android (#347) Breaking change due to changes in the native implementation for imgPath Release-As: 0.9.0 --- .../react/navsdk/MapViewController.java | 4 ++-- example/android/app/build.gradle | 2 +- .../android/app/src/main/assets/circle.png | Bin 0 -> 680 bytes .../SampleApp/Images.xcassets/Contents.json | 4 ++-- .../circle.imageset/Contents.json | 21 ++++++++++++++++++ .../circle.imageset/circle.png | Bin 0 -> 680 bytes example/src/controls/mapsControls.tsx | 12 +++++++--- 7 files changed, 35 insertions(+), 8 deletions(-) create mode 100644 example/android/app/src/main/assets/circle.png create mode 100644 example/ios/SampleApp/Images.xcassets/circle.imageset/Contents.json create mode 100644 example/ios/SampleApp/Images.xcassets/circle.imageset/circle.png diff --git a/android/src/main/java/com/google/android/react/navsdk/MapViewController.java b/android/src/main/java/com/google/android/react/navsdk/MapViewController.java index 68f023b..736ac11 100644 --- a/android/src/main/java/com/google/android/react/navsdk/MapViewController.java +++ b/android/src/main/java/com/google/android/react/navsdk/MapViewController.java @@ -144,7 +144,7 @@ public Marker addMarker(Map optionsMap) { MarkerOptions options = new MarkerOptions(); if (imagePath != null && !imagePath.isEmpty()) { - BitmapDescriptor icon = BitmapDescriptorFactory.fromPath(imagePath); + BitmapDescriptor icon = BitmapDescriptorFactory.fromAsset(imagePath); options.icon(icon); } @@ -290,7 +290,7 @@ public GroundOverlay addGroundOverlay(Map 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); diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 9696dac..2c48cd8 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -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() diff --git a/example/android/app/src/main/assets/circle.png b/example/android/app/src/main/assets/circle.png new file mode 100644 index 0000000000000000000000000000000000000000..e0714b10ba6aee97155283abcd6634b6f0040ef4 GIT binary patch literal 680 zcmV;Z0$2TsP)i{}%Du`1-+=1=~@?gN03|KyUrJeBrGmz+e`|TRz6{JWJ zb!4Icfq|U!p}BnBj=FVJ&GYQ^xGVtXELH;r@bVylFQBxqs}L}<0KyAk1FTvQ@(2H9 z1ET^yfCEsD2_g$1d~KiSBPXl2Za9t!B3pp)pdhj*#B1Oc_&JgAJ`jI_eRe97X~KXu z@XNrb0rQ`aPrDX9mH5KIZYJW}5O(I|#Ngt88~C1)_~!VwYb#K%)3weJYar@70$akN_kAaYq7>09;0M zcUEfL=t}?+fXk?u@+RZ-aicFepyLf+LLqc&y8w`#@3~h(?SC^&p@!6n)cSV;_z+eG zwbkSYU@da6r646r;LtToq#PeO3UNVgwUmRe1%$bvH~YSeAqg&UX5R@whzp$AA96X| z%;7EZv{>1-mk<9QV9D))KMR9U*){J+nJcz~k-M2sh_xrhcB2nYN*$Av1R<>WD+qCp z%3k#Z5yR5akISbG6C;&GoLgo*AmZ6H)dQjtAJ4Wq2aMTnoJ^4-^7scu67|jymYEv> O0000i{}%Du`1-+=1=~@?gN03|KyUrJeBrGmz+e`|TRz6{JWJ zb!4Icfq|U!p}BnBj=FVJ&GYQ^xGVtXELH;r@bVylFQBxqs}L}<0KyAk1FTvQ@(2H9 z1ET^yfCEsD2_g$1d~KiSBPXl2Za9t!B3pp)pdhj*#B1Oc_&JgAJ`jI_eRe97X~KXu z@XNrb0rQ`aPrDX9mH5KIZYJW}5O(I|#Ngt88~C1)_~!VwYb#K%)3weJYar@70$akN_kAaYq7>09;0M zcUEfL=t}?+fXk?u@+RZ-aicFepyLf+LLqc&y8w`#@3~h(?SC^&p@!6n)cSV;_z+eG zwbkSYU@da6r646r;LtToq#PeO3UNVgwUmRe1%$bvH~YSeAqg&UX5R@whzp$AA96X| z%;7EZv{>1-mk<9QV9D))KMR9U*){J+nJcz~k-M2sh_xrhcB2nYN*$Av1R<>WD+qCp z%3k#Z5yR5akISbG6C;&GoLgo*AmZ6H)dQjtAJ4Wq2aMTnoJ^4-^7scu67|jymYEv> O0000 = ({ mapViewController }) => { console.log(result); }; - const addMarker = async () => { + const addMarker = async (imgPath?: string) => { const cameraPosition = await mapViewController.getCameraPosition(); const marker: Marker = await mapViewController.addMarker({ @@ -115,14 +115,19 @@ const MapsControls: React.FC = ({ 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(); @@ -221,7 +226,8 @@ const MapsControls: React.FC = ({ mapViewController }) => { setZoom((zoom ?? defaultZoom) - 1); }} /> -