Coder Social home page Coder Social logo

Comments (6)

phegman avatar phegman commented on May 30, 2024 1

Thanks to @LKajan control events have now been implemented. If you pull down the latest NPM package you should be able to use them. Documentation has also been updated to explain how.

from vue-mapbox-gl.

toadkicker avatar toadkicker commented on May 30, 2024

Also tried:

const geo = this.map.addControl(new mapboxgl.GeolocateControl({ show: true, position: 'top-left', positionOptions: { enableHighAccuracy: true }}));
geo.on('geolocate', this.setAddress);

from vue-mapbox-gl.

LKajan avatar LKajan commented on May 30, 2024

Control events are not currently implemented yet. There is a pull request #38 for that though.

from vue-mapbox-gl.

toadkicker avatar toadkicker commented on May 30, 2024

Ok great I will pull that branch and try it out

from vue-mapbox-gl.

toadkicker avatar toadkicker commented on May 30, 2024

I upgraded but it doesn't look like it is working properly. Looking at the pull request, it doesn't look like $emit is implemented correctly. According to the docs the second argument is a callback. In PR #38 it is passing this.$emit('geolocate-geolocate', geolocate, position). Instead we would want to probably pass this.$emit('geolocate-geolocate', {event: geolocate, position: position}) so that position isn't dropped from the callback. Maybe I'm just not that familiar with $emit, so if there is something I am missing here please let me know.

Also in this example the final event is called result, but clearly that isn't documented in the control.

from vue-mapbox-gl.

phegman avatar phegman commented on May 30, 2024

Hi Todd,

It looks like the example you sent is referring to the Geocoder control which is actually not built into the main Mapbox library so is not implemented in this Vue component. The Geolocation events are working for me. The Vue $emit event uses the Rest Parameter to allow you to define additional arguments that are passed into the listener’s callback function. This allows you to do this.$emit('geolocate-geolocate', geolocate, position). If you take a look at app.js and index.html you can see an example of how the Geolocation control works. If you want to use the Geocoder control you can listen for the result event in the Mapbox load event.

Hope that is helpful!
Pete

from vue-mapbox-gl.

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.