perliedman / leaflet-control-geocoder

A simple geocoder form to locate places. Easily extended to multiple data providers.
http://www.liedman.net/leaflet-control-geocoder/
BSD 2-Clause "Simplified" License
564 stars 221 forks source link

.geocode property on callback #322

Closed mpgr04 closed 3 years ago

mpgr04 commented 3 years ago

Sorry to pop up here again with a question,

I have successfully overridden the defaultmarkgeocode event, but now I am wondering how to actually get to the .geocode property from my LeafletEvent without converting to any, which otherwise the property is not available.

Here is a code example:

   const mapboxProvider: Mapbox = new Mapbox({
            apiKey: this.Token,
        });

        const geocoder: GeocoderControl = new GeocoderControl({
            geocoder: mapboxProvider,
            defaultMarkGeocode: false
        });

        if (onMarkCallback == undefined) {

            geocoder.on("markgeocode", (e) => {

                /*e per default is a LeafletEvent*/

                const callbackAsAny: any = e as any; /*In which type to cast, to get the .geocode property*/

                const test = callbackAsAny.geocode;

            });

Thanks!