Skip to content

Conversation

Copy link

Copilot AI commented Jan 7, 2026

onMapClick did not fire when tapping interactive style layers (e.g., custom SymbolLayers added via addSymbolLayer), preventing users from querying features in the callback.

Changes

  • Android/iOS/Web: Modified tap handlers to fire map#onMapClick for all taps, while still firing feature#onTap when tapping interactive features
  • Previous behavior: mutually exclusive events (feature tap OR map click)
  • New behavior: both events fire when tapping interactive features (feature tap AND map click)

Impact

Users can now use queryRenderedFeaturesInRect in onMapClick callbacks regardless of what was tapped:

void _onMapClick(Point point, LatLng coordinates) async {
  // Now fires for all taps, including custom SymbolLayers
  final features = await mapController.queryRenderedFeaturesInRect(
    Rect.fromCenter(center: Offset(point.x, point.y), width: 50, height: 50),
    ['custom-nodes-signed'],
    null,
  );
}

No breaking changes. Existing onFeatureTapped callbacks continue to work as before.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • dl.google.com
    • Triggering command: /usr/lib/jvm/temurin-21-jdk-amd64/bin/java /usr/lib/jvm/temurin-21-jdk-amd64/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED -Xmx1536M -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -cp /home/REDACTED/.gradle/wrapper/dists/gradle-8.13-bin/5xuhj0ry160q40clulazy9h7d/gradle-8.13/lib/gradle-daemon-main-8.13.jar (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>[BUG] onMapClick not fired when tapping SymbolLayer</issue_title>
<issue_description>### Platforms

Android en iOS

Version of flutter maplibre_gl

0.20

Bug Description

I am adding a vector source to the map. After that, I add a SymbolLayer. Then, in the onMapClick event, I use the queryRenderedFeaturesInRect function to query all features that I click on. This function works fine when I click on the base map, but when I click on a symbol from my self-added vector layer, the onMapClick event is not triggered. When I retrieve the style IDs for the current style, it’s clear that my own SymbolLayer has been correctly added and exists.

Steps to Reproduce

  1. Add a vector source.
  2. Add a symbol layer based on this vector source.
  3. Implement queryRenderedFeaturesInRect in onMapClick.
  4. Click on map.
  5. When clicking outside the self added layer, onMapClick is fired.
  6. When clicking on a feature of the custom vector source, onMapClick is not fired.

Expected Results

Getting my own added features after onMapClick and queryRenderedFeaturesInRect.

Actual Results

Only features from basemap are triggering onMapClick. When clicking on a feature of the custom vector source, onMapClick is not fired.

Code Sample

Adding vector source:

await mapController.addSource(
      'custom-nodes',
      VectorSourceProperties(
        tiles: [
          'https://xxxx.com/$flavor/nodes/{z}/{x}/{y}.pbf'
        ],
        maxzoom: 18,
      ),
    );

Add layer:

await mapController.addSymbolLayer(
        'custom-nodes',
        'custom-nodes-signed',
        SymbolLayerProperties(
          iconImage: 'node-image-signed',
          iconSize: [
            Expressions.interpolate,
            ["linear"],
            [Expressions.zoom],
            10,
            0.52,
            12,
            0.64,
            13,
            0.70,
            15,
            0.72
          ],
          textAllowOverlap: false,
          iconAllowOverlap: true,
          iconIgnorePlacement: true,
          textField: ['get', 'label'],
          textColor: RPColors.colorNodes,
          textOpacity: 1.0,
          textSize: [
            Expressions.interpolate,
            ["linear"],
            [Expressions.zoom],
            10,
            8,
            12,
            9,
            13,
            10,
            15,
            11
          ],
          textAnchor: 'center',
          textJustify: 'center',
          visibility: 'visible',
          textFont: ['Noto Sans Bold', 'Open Sans Bold'],
        ),
        sourceLayer: 'nodes_data_$flavor',
        minzoom: 11,
        filter: [
          'all',
          ['!=', 'label', 'SP'],
          ['!=', 'label', 'TP'],
          ['!=', 'onlylf', 1],
          ['==', 'signed', 1]
        ]);

onMapClick:

void _onMapClick(Point<double> point, LatLng coordinates) async {

    final features = await mapController.queryRenderedFeaturesInRect(
      Rect.fromCenter(
        center: Offset(point.x, point.y), 
        width: 50, 
        height: 50,
      ),
      [
        'custom-nodes-signed',
      ],
      null,
    );

    if (features.isNotEmpty) {
      for (final feature in features) {
        print("Feature found: ${feature.id}");
      }
    } else {
      print("No Features Found");
    }
  }

</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits January 7, 2026 22:17
Modified Android, iOS, and Web implementations to always fire onMapClick
event regardless of whether an interactive feature was tapped. When tapping
an interactive feature, both onFeatureTapped and onMapClick will now fire.

Co-authored-by: gabbopalma <[email protected]>
Copilot AI changed the title [WIP] Fix onMapClick not firing for SymbolLayer Fire onMapClick for all map taps, including interactive features Jan 7, 2026
Copilot AI requested a review from gabbopalma January 7, 2026 22:22
@gabbopalma gabbopalma added this to the 0.26.0 milestone Jan 13, 2026
@gabbopalma gabbopalma marked this pull request as ready for review January 13, 2026 11:20
Copilot AI review requested due to automatic review settings January 13, 2026 11:20
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a bug where onMapClick callbacks were not firing when users tapped on interactive style layers (e.g., custom SymbolLayers). Previously, the events were mutually exclusive - either onFeatureTapped OR onMapClick would fire. Now both events fire when tapping interactive features, enabling users to query rendered features in onMapClick callbacks regardless of what was tapped.

Changes:

  • Modified tap handlers on Android, iOS, and Web platforms to always fire map#onMapClick for all taps
  • Feature tap events (feature#onTap) still fire when tapping interactive features
  • Changed from mutually exclusive event handling to both events firing together

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated no comments.

File Description
maplibre_gl_web/lib/src/maplibre_web_gl_platform.dart Updated Web platform tap handler to fire both events
maplibre_gl/ios/maplibre_gl/Sources/maplibre_gl/MapLibreMapController.swift Updated iOS platform tap handler to fire both events
maplibre_gl/android/src/main/java/org/maplibre/maplibregl/MapLibreMapController.java Updated Android platform tap handler to fire both events
maplibre_gl/android/gradle/wrapper/gradle-wrapper.jar Gradle wrapper binary update (unrelated to main PR purpose)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@gabbopalma gabbopalma added next version This feature will added in the next version bug Something isn't working labels Jan 13, 2026
@gabbopalma gabbopalma changed the base branch from main to release-0.26.0 January 13, 2026 23:47
@gabbopalma gabbopalma changed the title Fire onMapClick for all map taps, including interactive features feat: fire onMapClick for all map taps, including after interactive features Jan 13, 2026
@gabbopalma gabbopalma added enhancement New feature or request and removed bug Something isn't working labels Jan 13, 2026
@f1sh1918
Copy link

Very nice 👍
We've waited so long. I also tested this pr and works fine 🎉

@gabbopalma
Copy link
Collaborator

Happy for this! @f1sh1918

LGTM

@gabbopalma gabbopalma merged commit fe237c6 into release-0.26.0 Jan 15, 2026
23 checks passed
@gabbopalma gabbopalma deleted the copilot/fix-onmapclick-symbollayer-issue branch January 15, 2026 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request next version This feature will added in the next version

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] onMapClick not fired when tapping SymbolLayer

3 participants