GithubHelp home page GithubHelp logo

Comments (7)

domoritz avatar domoritz commented on May 18, 2024

Since I don't know about your requirements, why don't you add it and send a pull request which we then can discuss?

from leaflet-locatecontrol.

wraybowling avatar wraybowling commented on May 18, 2024

I second this request. I just ran into a need for being able to parse the data that results from the location found event. In my particular case, I'm going to push the resulting lat/long through the mapbox geocoder so i can display country/province/city.

Since Locate is being created with L.Control.extend() then I guess we should see how things like the geocoder enable the .on() function so events like 'found' fire events.

from leaflet-locatecontrol.

domoritz avatar domoritz commented on May 18, 2024

@wraybowling in your case, you can just subscribe to the location found even on the map. It sounds like to don't want to change the logic of the locate control.

from leaflet-locatecontrol.

wraybowling avatar wraybowling commented on May 18, 2024

Could you provide an example? I thought I understood what you meant, but then I broke my fiddle. http://jsfiddle.net/rgbk/JgmE3/11/

from leaflet-locatecontrol.

gmccrackin avatar gmccrackin commented on May 18, 2024

I'm not sure if you figured this out or not. So I will try to help if I can.

You had:

var map = L.mapbox.map('map', mapboxString)
          .addControl(
                L.mapbox.geocoderControl(mapboxString, {})
                .on('select',displayResults)
                .on('found',displayResults)
            )
            .addControl(
                L.control.locate().on('found', displayResults)
            )
;

I believe you want:

var map = L.mapbox.map('map', mapboxString)
          .addControl(
                L.mapbox.geocoderControl(mapboxString, {})
                .on('select',displayResults)
                .on('found',displayResults)
            )
            .addControl(
                L.control.locate()
            ).on('locationfound', displayResults)
;

This is because the event fires on the map object not the locate control. Hopefully this was helpful.

from leaflet-locatecontrol.

domoritz avatar domoritz commented on May 18, 2024

Thanks @gmccrackin. I'm not sure what the right thing is so I fired the events on the map. If that is not the standard, it might be worth changing.

from leaflet-locatecontrol.

gmccrackin avatar gmccrackin commented on May 18, 2024

Yeah I think firing it on the map is the standard for this.

from leaflet-locatecontrol.

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.