Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript support #12

Closed
ChaudhryAtif opened this issue Nov 28, 2017 · 10 comments
Closed

Typescript support #12

ChaudhryAtif opened this issue Nov 28, 2017 · 10 comments

Comments

@ChaudhryAtif
Copy link

ChaudhryAtif commented Nov 28, 2017

Can Typerscript support be added for the sidebar? The parent repo has a file that can be dropped-in, or used as a starting point.
leaflet-sidebar.d.ts

Currently gives me the following error:

Property 'sidebar' does not exist on type 'typeof control'.

When trying to do the following (using autopan example):

L.control.sidebar('sidebar', { autopan: true })
    .addTo(map)
    .open('autopan');

And if possible, please add an angular 2+ example.

@nickpeihl
Copy link
Collaborator

Hi @ChaudhryAtif

I am not familiar with TypeScript or Angular. Would you like to submit pull requests for including TypeScript definitions and an Angular example?

@ChaudhryAtif
Copy link
Author

ChaudhryAtif commented Nov 29, 2017

The parent repo has a typing file, but this fork is ahead of the parent repo, So typing file will need to be modified, but I do not have any experience in writing typings for a JS project. If someone can write the typing file, I can probably add an Angular example.

@noerw Are you familiar with Typescript?

@noerw
Copy link
Owner

noerw commented Nov 29, 2017

Yeah, a little bit. I can look into it.
Can't help out with angular 2 though

@ChaudhryAtif
Copy link
Author

I started looking into it as well. I will keep you guys posted on progress. Using leaflet-sidebar.d.ts as base.

@noerw
Copy link
Owner

noerw commented Jan 16, 2018

fixed in 9873c90

@noerw noerw closed this as completed Jan 16, 2018
@ChaudhryAtif
Copy link
Author

@nickpeihl @noerw Will the version get a bump? B/c npm install 3.0.0 doesn't seem to give the latest changes.

@noerw
Copy link
Owner

noerw commented Jan 19, 2018

I just released v3.0.1

@cwgrc2
Copy link

cwgrc2 commented Apr 13, 2020

Can anyone here please give an example on actually how to use this in Typescript Angular? A little late to the game here sorry. I have been trying to integrate leaflet-sidebar-v2 for two days now with no luck. I tried '@runette/ngx-leaflet-sidebar' Angular wrapper but that requires a certain version of Angular to work.

Thanks!

@ChaudhryAtif
Copy link
Author

ChaudhryAtif commented Apr 14, 2020

@cwgrc2 What have you tried? Since leaflet-sidebar.d.ts is inside the project, you shouldn't have to do a lot other than importing it.

Hopefully this helps:

// package.json
npm install -S leaflet leaflet-sidebar-v2
npm install -D @types/leaflet

// html
<div id="sidebar" class="leaflet-sidebar collapsed">
    ...
</div>

// controller
import * as L from 'leaflet';
import 'leaflet-sidebar-v2';

getSidebar() {
    return L.control.sidebar({container: 'sidebar', autopan: true});
}

@cwgrc2
Copy link

cwgrc2 commented Apr 14, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants