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

Overwriting the "markgeocode" event not possible in TypeScript #320

Closed mpgr04 closed 3 years ago

mpgr04 commented 3 years ago

Currently I'm using this library with TypeScript, which has worked fine so far. But now I have encountered the problem that I am not able to override the "markgeocode" event.

I proceeded as described in the API docs, also I set the defaultMarkGeocode property to false.

But in TypeScript I get the following error:

 Argument of type '"markgeocode"' is not assignable to parameter of type '"tileunload" | "tileloadstart" | "tileload"'.

simon04 commented 3 years ago

Would you mind sharing a small example how to reproduce this error, please? You might want to start with the demo from https://github.com/perliedman/leaflet-control-geocoder/blob/master/demo/index.html – Thanks!

mpgr04 commented 3 years ago

I have now tried several things and found that it works fine in normal JS, even in TypeScript if the GeoCoder is converted to any type beforehand.

The problem can also be avoided by implementing a separate property using declaration merging.

mpgr04 commented 3 years ago

Hi, quick update, the problem has certainly settled!

Blame was a stupidly named variable which did not point to the real control but to the map, now everything works.

Sorry for wasting your time!