Pages UI
Search…
Maps
Maps in Pages will only support Google maps. The premium plugin "Mapplic" will not be included in the angular package as it only supports jQuery. However you could still use it from the HTML version and import it to Angular package.
Note that using jQuery will cause unwanted increase in package size and will be a bad practice for templating causing unwanted issues.
GitHub - ng2-ui/map: Angular Google Maps Directives
GitHub

Importing

First import it to your app module or any submodule as you wish
1
import { NguiMapModule} from '@ngui/map';
2
@NgModule({
3
imports: [NguiMapModule.forRoot({apiUrl: 'https://maps.google.com/maps/api/js?key=YOUR_KEY_HERE'}),...]
4
})
5
export class AppModule(){}
Copied!

How to use

HTML
Typescript
1
<ngui-map [zoom]="zoomLevel" [styles]="styles" [center]="center" [disableDefaultUI]="disableDefaultUI"></ngui-map>
Copied!
1
import { Component, OnInit } from '@angular/core';
2
import { pagesToggleService } from '../../@pages/services/toggler.service'
3
import { Subscriber } from 'rxjs/Subscriber'
4
5
@Component({
6
selector: 'google-map-page',
7
templateUrl: './google.component.html',
8
styleUrls: ['./google.component.scss']
9
})
10
export class GoogleMapPage implements OnInit {
11
zoomLevel = 11;
12
center = {lat: 40.6700, lng: -73.9400};
13
disableDefaultUI = true;
14
styles = [{
15
featureType: 'water',
16
elementType: 'all',
17
stylers: [{
18
hue: '#e9ebed'
19
}, {
20
saturation: -78
21
}, {
22
lightness: 67
23
}, {
24
visibility: 'simplified'
25
}]
26
}, {
27
featureType: 'landscape',
28
elementType: 'all',
29
stylers: [{
30
hue: '#ffffff'
31
}, {
32
saturation: -100
33
}, {
34
lightness: 100
35
}, {
36
visibility: 'simplified'
37
}]
38
}, {
39
featureType: 'road',
40
elementType: 'geometry',
41
stylers: [{
42
hue: '#bbc0c4'
43
}, {
44
saturation: -93
45
}, {
46
lightness: 31
47
}, {
48
visibility: 'simplified'
49
}]
50
}, {
51
featureType: 'poi',
52
elementType: 'all',
53
stylers: [{
54
hue: '#ffffff'
55
}, {
56
saturation: -100
57
}, {
58
lightness: 100
59
}, {
60
visibility: 'off'
61
}]
62
}, {
63
featureType: 'road.local',
64
elementType: 'geometry',
65
stylers: [{
66
hue: '#e9ebed'
67
}, {
68
saturation: -90
69
}, {
70
lightness: -8
71
}, {
72
visibility: 'simplified'
73
}]
74
}, {
75
featureType: 'transit',
76
elementType: 'all',
77
stylers: [{
78
hue: '#e9ebed'
79
}, {
80
saturation: 10
81
}, {
82
lightness: 69
83
}, {
84
visibility: 'on'
85
}]
86
}, {
87
featureType: 'administrative.locality',
88
elementType: 'all',
89
stylers: [{
90
hue: '#2c2e33'
91
}, {
92
saturation: 7
93
}, {
94
lightness: 19
95
}, {
96
visibility: 'on'
97
}]
98
}, {
99
featureType: 'road',
100
elementType: 'labels',
101
stylers: [{
102
hue: '#bbc0c4'
103
}, {
104
saturation: -93
105
}, {
106
lightness: 31
107
}, {
108
visibility: 'on'
109
}]
110
}, {
111
featureType: 'road.arterial',
112
elementType: 'labels',
113
stylers: [{
114
hue: '#bbc0c4'
115
}, {
116
saturation: -93
117
}, {
118
lightness: -2
119
}, {
120
visibility: 'simplified'
121
}]
122
}];
123
124
constructor(private toggler:pagesToggleService) { }
125
126
ngOnInit() {
127
this.toggler.setBodyLayoutClass("no-header");
128
this.toggler.toggleFooter(false);
129
this.toggler.setPageContainer("full-height");
130
this.toggler.setContent("full-width full-height overlay-footer");
131
this.toggler.setHeaderClass("transparent");
132
}
133
134
zoomIn(){
135
this.zoomLevel++;
136
}
137
138
zoomOut(){
139
this.zoomLevel--;
140
}
141
142
}
Copied!
Copy link