GithubHelp home page GithubHelp logo

Comments (9)

christopherdro avatar christopherdro commented on May 8, 2024

@lelandrichardson Is there anyway we can set the keyor ref prop and have either those be available in the event callback?

from react-native-maps.

lelandrichardson avatar lelandrichardson commented on May 8, 2024

@christopherdro i don't think key is available in the context of the child... and I'm not sure ref is the best way to do it as refs come with a bit of overhead, and also wont be available in functional stateless components.

from react-native-maps.

ghamaide avatar ghamaide commented on May 8, 2024

So at the moment, it's not possible to know which marker triggered an onMarkerSelect method for example ?

from react-native-maps.

lelandrichardson avatar lelandrichardson commented on May 8, 2024

@ghamaide You can use the onSelect event on the marker directly, and you can also get the marker node by using the event.target property.

from react-native-maps.

ghamaide avatar ghamaide commented on May 8, 2024

I'm a bit new to RN. How do I get info on the marker that triggered an onMarkerSelect method knowing the event.nativeEvent.target (which returns an integer, for example 514). I don't know what that integer represents in fact. This is what onMarkerSelect returns :

{ dispatchConfig: { registrationName: 'onSelect' },
  dispatchMarker: '.r[1]{TOP_LEVEL}[0].0.0.3.$navigator.0.$nav0.0.$mapcontainer.$map.$465',
  nativeEvent: 
   { id: 'unknown',
     coordinate: { longitude: 2.3575678, latitude: 48.8798646 },
     target: 514,
     action: 'marker-select' },
  type: undefined,
  target: undefined,
  currentTarget: 514,
  eventPhase: undefined,
  bubbles: undefined,
  cancelable: undefined,
  timeStamp: 1455286645886,
  defaultPrevented: undefined,
  isTrusted: undefined,
  isDefaultPrevented: [Function],
  isPropagationStopped: [Function],
  _dispatchListeners: [Function],
  _dispatchIDs: '.r[1]{TOP_LEVEL}[0].0.0.3.$navigator.0.$nav0.0.$mapcontainer.$map.$465' }

from react-native-maps.

frankbolviken avatar frankbolviken commented on May 8, 2024

+1 for this. Im having a hard time tying this together.

My marker definition:
<MapView.Marker key={station.csmd.id} title= {'' + station.csmd.id} coordinate={ station.coords } onSelect= {this.onStationTap} image={require('../../assets/station.png')} />

As you can see from the image below, the only slight reference to the marker I have tapped is the last part of the dispatchMarker string in the event in the callback. currentTarget etc is some random number as far as I can see, not attached to the marker itself. Is this expected? Or am i doing something wrong here?

screen shot 2016-03-29 at 15 28 38

from react-native-maps.

frankbolviken avatar frankbolviken commented on May 8, 2024

You would actually think that a basic thing like being able to quickly see which marked was tapped on would be perhaps the most needed functionality of a map component. So I'm a bit surprise that this doesn't get more attention.

from react-native-maps.

frankbolviken avatar frankbolviken commented on May 8, 2024

The way I solved this for anyone interested was that I did a substring of the dispatchId prop to get the id (last digits behind $). Then using this id with "this.refs[id]". When initialising the markers i added the station as a parameter on the Marker.

from react-native-maps.

christopherdro avatar christopherdro commented on May 8, 2024

I’m closing this issue because it has been inactive for a while. This probably means that it is not reproducible or it has been fixed in a newer version. If it’s an enhancement and hasn’t been taken on for so long, then it seems no one has the time to implement this.

Please reopen if you still encounter this issue with the latest stable version.

Thank you!

from react-native-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.