mirror of
https://github.com/akveo/ngx-admin.git
synced 2025-12-17 16:00:14 +01:00
leaflet maps
This commit is contained in:
parent
6cf83c8903
commit
1b2b7e42b1
13 changed files with 58 additions and 5 deletions
|
|
@ -230,6 +230,7 @@ module.exports = {
|
||||||
"Tether": 'tether',
|
"Tether": 'tether',
|
||||||
"window.Tether": "tether",
|
"window.Tether": "tether",
|
||||||
"GoogleMapsLoader": "google-maps",
|
"GoogleMapsLoader": "google-maps",
|
||||||
|
"L": "leaflet"
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,7 @@
|
||||||
"font-awesome-sass-loader": "^1.0.1",
|
"font-awesome-sass-loader": "^1.0.1",
|
||||||
"google-maps": "^3.2.1",
|
"google-maps": "^3.2.1",
|
||||||
"jquery": "^2.2.3",
|
"jquery": "^2.2.3",
|
||||||
|
"leaflet-map": "^0.2.1",
|
||||||
"normalize.css": "^4.1.1",
|
"normalize.css": "^4.1.1",
|
||||||
"rxjs": "5.0.0-beta.2",
|
"rxjs": "5.0.0-beta.2",
|
||||||
"tether": "^1.2.4",
|
"tether": "^1.2.4",
|
||||||
|
|
|
||||||
|
|
@ -15,12 +15,11 @@ export class GoogleMaps {
|
||||||
constructor(private _elementRef:ElementRef) {
|
constructor(private _elementRef:ElementRef) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
|
||||||
}
|
|
||||||
|
|
||||||
ngAfterViewInit() {
|
ngAfterViewInit() {
|
||||||
|
let el = DOM.querySelector(this._elementRef.nativeElement, '.google-maps');
|
||||||
|
|
||||||
GoogleMapsLoader.load((google) => {
|
GoogleMapsLoader.load((google) => {
|
||||||
new google.maps.Map(DOM.querySelector(this._elementRef.nativeElement, '.google-maps'), {
|
new google.maps.Map(el, {
|
||||||
center: new google.maps.LatLng(44.5403, -78.5463),
|
center: new google.maps.LatLng(44.5403, -78.5463),
|
||||||
zoom: 8,
|
zoom: 8,
|
||||||
mapTypeId: google.maps.MapTypeId.ROADMAP
|
mapTypeId: google.maps.MapTypeId.ROADMAP
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
<ba-card title="GoogleMaps" baCardClass="popular-app medium-card" class="viewport100">
|
<ba-card title="Google Maps" baCardClass="popular-app medium-card" class="viewport100">
|
||||||
<div class="google-maps"></div>
|
<div class="google-maps"></div>
|
||||||
</ba-card>
|
</ba-card>
|
||||||
|
|
|
||||||
1
src/app/pages/maps/components/leafletMaps/index.ts
Normal file
1
src/app/pages/maps/components/leafletMaps/index.ts
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
export * from './leafletMaps.component';
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
import {Component, ViewEncapsulation, ElementRef} from 'angular2/core';
|
||||||
|
import {BaCard} from '../../../../theme';
|
||||||
|
import {DOM} from "angular2/src/platform/dom/dom_adapter";
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'google-maps',
|
||||||
|
pipes: [],
|
||||||
|
providers: [],
|
||||||
|
// otherwise maps won't work
|
||||||
|
encapsulation: ViewEncapsulation.None,
|
||||||
|
styles: [require('leaflet/dist/leaflet.css'), require('./leafletMaps.scss')],
|
||||||
|
directives: [BaCard],
|
||||||
|
template: require('./leafletMaps.html'),
|
||||||
|
})
|
||||||
|
export class LeafletMaps {
|
||||||
|
|
||||||
|
constructor(private _elementRef:ElementRef) {
|
||||||
|
}
|
||||||
|
|
||||||
|
ngAfterViewInit() {
|
||||||
|
let el = DOM.querySelector(this._elementRef.nativeElement, '.leaflet-maps');
|
||||||
|
|
||||||
|
L.Icon.Default.imagePath = 'assets/img/theme/vendor/leaflet';
|
||||||
|
var map = L.map(el).setView([51.505, -0.09], 13);
|
||||||
|
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
|
||||||
|
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
|
||||||
|
}).addTo(map);
|
||||||
|
|
||||||
|
L.marker([51.5, -0.09]).addTo(map)
|
||||||
|
.bindPopup('A pretty CSS3 popup.<br> Easily customizable.')
|
||||||
|
.openPopup();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
<ba-card title="Leaflet Maps" baCardClass="popular-app medium-card" class="viewport100">
|
||||||
|
<div class="leaflet-maps"></div>
|
||||||
|
</ba-card>
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
.leaflet-maps {
|
||||||
|
//TODO: hotfix
|
||||||
|
height: 320px;
|
||||||
|
}
|
||||||
|
|
@ -2,6 +2,7 @@ import {Component, ViewEncapsulation} from 'angular2/core';
|
||||||
import {RouteConfig} from 'angular2/router';
|
import {RouteConfig} from 'angular2/router';
|
||||||
|
|
||||||
import {GoogleMaps} from './components/googleMaps';
|
import {GoogleMaps} from './components/googleMaps';
|
||||||
|
import {LeafletMaps} from "./components/leafletMaps";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'maps',
|
selector: 'maps',
|
||||||
|
|
@ -17,6 +18,11 @@ import {GoogleMaps} from './components/googleMaps';
|
||||||
path: '/google-maps',
|
path: '/google-maps',
|
||||||
useAsDefault: true
|
useAsDefault: true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'LeafletMaps',
|
||||||
|
component: LeafletMaps,
|
||||||
|
path: '/leaflet-maps',
|
||||||
|
},
|
||||||
])
|
])
|
||||||
export class Maps {
|
export class Maps {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,10 @@ export class SidebarService {
|
||||||
{
|
{
|
||||||
title: 'Google Maps',
|
title: 'Google Maps',
|
||||||
name: 'GoogleMaps',
|
name: 'GoogleMaps',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Leaflet Maps',
|
||||||
|
name: 'LeafletMaps',
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
||||||
BIN
src/assets/img/theme/vendor/leaflet/marker-icon-2x.png
vendored
Normal file
BIN
src/assets/img/theme/vendor/leaflet/marker-icon-2x.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.9 KiB |
BIN
src/assets/img/theme/vendor/leaflet/marker-icon.png
vendored
Normal file
BIN
src/assets/img/theme/vendor/leaflet/marker-icon.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.7 KiB |
1
src/custom-typings.d.ts
vendored
1
src/custom-typings.d.ts
vendored
|
|
@ -31,6 +31,7 @@ import * as _ from 'lodash'
|
||||||
|
|
||||||
declare var $:any;
|
declare var $:any;
|
||||||
declare var GoogleMapsLoader:any;
|
declare var GoogleMapsLoader:any;
|
||||||
|
declare var L:any;
|
||||||
|
|
||||||
// Extra variables that live on Global that will be replaced by webpack DefinePlugin
|
// Extra variables that live on Global that will be replaced by webpack DefinePlugin
|
||||||
declare var ENV: string;
|
declare var ENV: string;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue