I can suggest you a workaround until angular-cli get better support for 3rd party libs. It worked for me :)
First go to the project directory and type
npm install leaflet --save
then open your angular-cli-build.js and add this line
vendorNpmFiles: [
..................
'leaflet/**/*.js',
....................
]
now open your src/system-config.ts, write
const map:any ={
..................
'ng2-bootstrap''leaflet': 'vendor/leaflet/dist',
....................
}
and
const packages: any = {
'leaflet': {
format: 'cjs'
}
};
Open your src/index.html, add this
<script type="text/javascript" src="vendor/leaflet/dist/leaflet.js"></script>
and dont forget to add the css file also
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.css" />
Now open your component where you want to use Leaflet
declare let L: any;
@Component({
moduleId: module.id,
selector: 'app-map',
templateUrl: 'map.component.html',
styleUrls: ['map.component.css']
})
export class MapComponent implements OnInit, AfterViewInit {
leafletMap: any;
ngAfterViewInit() {
this.leafletMap = L.map("map").setView([23.709921, 90.407143], 7);
}
}
Tada!! your map loaded :D