Skip to content

Commit 0f56454

Browse files
author
farfromrefug
committed
fix: title/subtitle are now optional. If not defined there wont be a callout
1 parent bc0203c commit 0f56454

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

src/ui-mapbox/index.ios.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,9 @@ export class Mapbox extends MapboxCommon implements MapboxApi {
707707
if (this.selectedMarker && !this.isMarkerSelected(marker)) {
708708
this.deselectMarker(this.selectedMarker);
709709
}
710-
await this.showCalloutForMarkerById(marker.id + '');
710+
if (marker.title || marker.subtitle) {
711+
await this.showCalloutForMarkerById(marker.id + '');
712+
}
711713
resolve();
712714
} catch (ex) {
713715
if (Trace.isEnabled()) {
@@ -1435,7 +1437,7 @@ export class Mapbox extends MapboxCommon implements MapboxApi {
14351437

14361438
toggleCalloutForMarkerById(markerId: string): void {
14371439
const m = this._markers.find((x) => `${x.id}` === markerId);
1438-
if (!m || !m.id) return;
1440+
if (!m || !m.id || (!m.title && !m.subtitle)) return;
14391441
const exists = this.bridgeInstance.hasViewAnnotationForMarker(markerId);
14401442
if (exists) this.hideCalloutForMarkerById(markerId);
14411443
else this.showCalloutForMarkerById(markerId);

src/ui-mapbox/markers/Marker.android.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ export class AndroidMarker {
1818
layerId: string;
1919

2020
constructor(opts: { id: string | number; position: com.mapbox.geojson.Point; icon: android.graphics.Bitmap; title?: string; snippet?: string }) {
21-
if (!opts.title && !opts.snippet) {
22-
throw new Error('Marker should have either title or snippet!');
23-
}
2421

2522
this.position = opts.position;
2623
this.id = opts.id;

src/ui-mapbox/markers/MarkerManager.android.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -228,13 +228,14 @@ export class MarkerManager {
228228
this.deselectMarker(this.selectedMarker);
229229
}
230230
this.selectedMarker = marker;
231-
232-
this.prepareViewAnnotation(marker, (e) => {
233-
// info Window tapped.
234-
if (!this.onInfoWindowTapped(marker)) {
235-
this.deselectMarker(marker);
236-
}
237-
});
231+
if (marker.title || marker.snippet) {
232+
this.prepareViewAnnotation(marker, (e) => {
233+
// info Window tapped.
234+
if (!this.onInfoWindowTapped(marker)) {
235+
this.deselectMarker(marker);
236+
}
237+
});
238+
}
238239
}
239240

240241
deselectMarker(marker: AndroidMarker) {

0 commit comments

Comments
 (0)