Maps UI with typical features and data visualization
angular: 15
npm: 8
-
Leaflet
-
npm install leaflet npm install --save-dev @types/leaflet
-
Add leaflet styles
angular.json
{ ... "projects": { "architect": { "styles": [ ... "./node_modules/leaflet/dist/leaflet.css" ], } } ... }
-
Import leaflet library in the component of interest
import * as L from 'leaflet';
-
Initialize map (
L.map
)private map!:L.Map; private initMap() { const mapOptions:L.MapOptions = { center: this.mapService.getMapCenter(), zoom: 15, zoomControl: false } this.map = L.map('map', mapOptions); const tiles:L.TileLayer = L.tileLayer(this.mapService.getMapTileLayer(), { maxZoom: 18, minZoom: 3, attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>' }); tiles.addTo(this.map); L.control.zoom({ position: "bottomright" }).addTo(this.map); }
- Add map
div
to template-
<div class="map-container"> <div class="map-frame"> <div id="map"></div> </div> </div>
-
.map-container { position: absolute; top: 0; bottom: 0; left: 0; right: 0; // margin: 0.5rem; .map-frame { #map { height: 100%; } } }
-
- Add map
-
-
Install
angular-cli-ghpages
npm install -g angular-cli-ghpages
-
Uncomment
/dist
in.gitignore
-
Create a new branch
git branch gh-pages git checkout gh-pages
-
Push changes to new remote branch
git push -f -u origin gh-pages
-
Build project
ng build --prod --base-href https://[username].github.io/[repo]/ --deploy-url https://[username].github.io/[repo]/
-
Publish to gh-pages
ngh --dir=dist/[project-name]
Sources: