Giter VIP home page Giter VIP logo

Comments (16)

mattijsf avatar mattijsf commented on May 22, 2024 1

@mfazekas Thanks for pointing it out. Yes it was caused by the same problem, just added a commit to the PR that fixes the problem for these map related events.

from maps.

mattijsf avatar mattijsf commented on May 22, 2024

Does it only happen when clustering is enabled?

from maps.

smol-honk avatar smol-honk commented on May 22, 2024

I've also noticed that the onPress in UserLocation calls twice with each press.

from maps.

carsonaaberle avatar carsonaaberle commented on May 22, 2024

It is being called twice as for me on Android only for MapView onPress. I am on 7.0.0-rc-2

from maps.

makirby avatar makirby commented on May 22, 2024

We came under the same problem. I pinned it down to duplicate events being dispatched once by the ShapeSource and once by the UIManager.

This patch fixes it but I've haven't had time yet to check if it creates any other side effects.

diff --git a/node_modules/@react-native-mapbox/maps/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/AbstractEventEmitter.java b/node_modules/@react-native-mapbox/maps/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/AbstractEventEmitter.java
index 7fa9007..d8a093c 100644
--- a/node_modules/@react-native-mapbox/maps/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/AbstractEventEmitter.java
+++ b/node_modules/@react-native-mapbox/maps/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/AbstractEventEmitter.java
@@ -42,12 +42,13 @@ abstract public class AbstractEventEmitter<T extends ViewGroup> extends ViewGrou
             return;
         }
 
-        mRateLimitedEvents.put(eventCacheKey, System.currentTimeMillis());
-        mEventDispatcher.dispatchEvent(new AbstractEvent(event.getID(), event.getKey(), event.toJSON()));
-
         RCTEventEmitter emitter = EventEmitter.getViewEmitter(mRCTAppContext);
+        mRateLimitedEvents.put(eventCacheKey, System.currentTimeMillis());
+        // try to get view dispatcher, otherwise use the UImanager emitter
         if (emitter != null) {
             emitter.receiveEvent(event.getID(), event.getKey(), event.toJSON());
+        } else {
+            mEventDispatcher.dispatchEvent(new AbstractEvent(event.getID(), event.getKey(), event.toJSON()));
         }
     }
 

from maps.

mfazekas avatar mfazekas commented on May 22, 2024

Looks like to me it's a result of merge error:

One change mEventDispatcher.dispatchEvent( was nitaliano/react-native-mapbox-gl#1508

react-native-mapbox-gl/maps@7458dd1#diff-67b563fd89b6669ee1bc084451e62e57R41

other was from expression changes:
nitaliano/react-native-mapbox-gl@fc8901f#diff-67b563fd89b6669ee1bc084451e62e57R42

I guess the first change should win, so we should keep mEventDispatcher.dispatchEvent(new AbstractEvent(event.getID(), event.getKey(), event.toJSON())); and remove emitter related lines.

from maps.

makirby avatar makirby commented on May 22, 2024

Yeah that looks like what's happened. I'll get it into a PR later today.

edit: actually after some testing it looks like the emitter is still needed for certain events

from maps.

kristfal avatar kristfal commented on May 22, 2024

from maps.

mfazekas avatar mfazekas commented on May 22, 2024

edit: actually after some testing it looks like the emitter is still needed for certain events

I've implemented the fix in #137. Let me know if you're seeing double events/missing events now.

from maps.

bwandersOA avatar bwandersOA commented on May 22, 2024

All - Thanks for working a solution to this one and actively maintaining this repo! We are holding off on releasing our Android app until we work this fix in. When might we expect the new release to be tagged and up on npm?

from maps.

makirby avatar makirby commented on May 22, 2024

Apologies for not submitting a fix, after removing the emitter.receiveEvent we noticed some callbacks on the Map component were no longer firing. One of which was onDidFinishLoadingStyle. Has anyone else noticed the same?

from maps.

kristfal avatar kristfal commented on May 22, 2024

@makirby is this in production env, or only in development mode after a reload of the JS side?

from maps.

makirby avatar makirby commented on May 22, 2024

I could still get it to happen in production, albeit more intermittently.
I suspected it was something to do with throttling so did a rebuild with the didStartRenderingFrame & didFinishRenderingFrame listeners removed, with those removed the onDidFinishLoadingStyle events would then fire every time, in dev and production.

from maps.

mfazekas avatar mfazekas commented on May 22, 2024

@makirby might or might not related to #177

from maps.

makirby avatar makirby commented on May 22, 2024

@mfazekas yeah that looks like the cause

from maps.

Beamanator avatar Beamanator commented on May 22, 2024

Hmmm I'm trying to get a ShapeSource's onPress to work, but it's not running the function at all! Any advice?

Some important packages I'm using:

"@react-native-mapbox-gl/maps": "^7.0.4",
"react": "^16.9.0",
"react-native": "^0.60.5",

Platfrom: [Android]
SDK Version [28]

I've been using very similar code to this example but including onPress={(e) => console.log("shapesource press", e)} prop in the ShapeSource component.

I am not getting any errors or anything, and no console log messages either. Is anyone else running into a similar issue with the above packages?

from maps.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.