more typescripting

This commit is contained in:
muerwre 2019-02-20 17:52:42 +07:00
parent 5699a7abb7
commit 628b96c4ab
7 changed files with 144 additions and 103 deletions

View file

@ -9,30 +9,26 @@ import 'leaflet/dist/leaflet.css';
import { PROVIDER } from '$config/frontend';
import { DEFAULT_PROVIDER, PROVIDERS } from '$constants/providers';
interface IMap {
map: MapInterface;
tileLayer: TileLayer;
setProvider: (provider: string) => void;
interface Props {
container: string
}
export class Map implements IMap {
constructor({ container }) {
export class Map {
constructor({ container }: Props) {
this.map = map(container).setView([55.0153275, 82.9071235], 13);
// todo: change coords?
this.tileLayer = tileLayer(PROVIDER.url, {
attribution: 'Независимое Велосообщество',
maxNativeZoom: 18,
maxZoom: 18,
});
this.tileLayer.addTo(this.map);
}
map;
tileLayer;
map: MapInterface;
tileLayer: TileLayer = tileLayer(PROVIDER.url, {
attribution: 'Независимое Велосообщество',
maxNativeZoom: 18,
maxZoom: 18,
});
setProvider = (provider) => {
setProvider = (provider: string): void => {
const { url } = (provider && PROVIDERS[provider] && PROVIDERS[provider]) || PROVIDERS[DEFAULT_PROVIDER];
this.tileLayer.setUrl(url);