Closed rklerck closed 7 years ago
@rklerck You can simply import the library with
import 'leaflet.vectorgrid';
It will automatically patch the L
object with the vectorGrid
namespace if the type definition is written right. If you are interested in seeing a live example, take a look at ngx-leaflet-starter.
Thnx for the quick response!
Unfortunately, when I do it like that. Typescript complains with " Cannot find name 'L' ".
import {Component} from '@angular/core';
import {Config, NavController} from 'ionic-angular';
import {PropertyService} from '../../providers/property-service-mock';
import {PropertyDetailPage} from '../property-detail/property-detail';
import leaflet from 'leaflet';
import 'leaflet.vectorgrid';
L.vectorGrid.protobuf(
I didn't understand it but now I do finally, had to create a .d.ts file.. that's what you meant with "if the type definition is written right".
// in the global namesapce "L"
declare namespace L {
// there is a child namespace "vectorGrid"
namespace vectorGrid {
export function protobuf(url: any, options?: any): any;
}
}
this wont build in production mode
Probably a stupid one, but I can't figure it out. I'm trying to import de module in a typescript file. But how can I do this if the module has no exports?
I'm trying to do:
import .... from 'leaflet.vectorgrid ';
So I can do the L.vectorGrid.protobuf(
Sorry if it's an obvious one, but I really can't get it to work.