Skip to content

Commit

Permalink
make feature tap detection work for features with a null id on ios (s…
Browse files Browse the repository at this point in the history
…ame as android) (maplibre#357)

Feature Id nullable on android but not on iOS.

On android the feature id can be null which works fine in our app but on
iOS clicking on points of interest the reaction is the same as clicking
elsewhere on the map.

In the android code 
![Screenshot 2023-12-12 at 13 42
00](https://github.com/maplibre/flutter-maplibre-gl/assets/26603883/a532aa76-9ec4-4bf4-8da3-b673989a85e6)

null is a valid value. I adapted the iOS code to allow for the same
behaviour.

Co-authored-by: m0nac0 <58807793+m0nac0@users.noreply.github.com>
  • Loading branch information
lunaticcoding and m0nac0 authored Dec 15, 2023
1 parent f234dd5 commit 1fd4001
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ios/Classes/MapboxMapController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -989,9 +989,9 @@ class MapboxMapController: NSObject, FlutterPlatformView, MGLMapViewDelegate, Ma
let point = sender.location(in: mapView)
let coordinate = mapView.convert(point, toCoordinateFrom: mapView)

if let feature = firstFeatureOnLayers(at: point), let id = feature.identifier {
if let feature = firstFeatureOnLayers(at: point) {
channel?.invokeMethod("feature#onTap", arguments: [
"id": id,
"id": feature.identifier,
"x": point.x,
"y": point.y,
"lng": coordinate.longitude,
Expand Down

0 comments on commit 1fd4001

Please sign in to comment.