Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added optional parameter to the aui-leaflet-locate-control to specify the zoomlevel #106

Merged
merged 13 commits into from
Mar 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/).

- `map` Fixed an issue where the default map layer wouldn't show on iOS devices.
- `calendar` Fixed an issue where the calendar doesn't jump to a predefined date.
- `map` added possibility to set the zoom level of the `aui-leaflet-locate-control`.
- `forms/datepicker` Fixed an issue where the datepicker doesn't initialize when being cleared.

## [1.1.0] - 2019-02-05
Expand Down
2 changes: 1 addition & 1 deletion packages/map/examples/src/map/pages/demo/demo.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ <h1 class="h3 u-margin-bottom">Map</h1>
<aui-leaflet-fullscreen-control></aui-leaflet-fullscreen-control>
</div>
<div controls bottom left>
<aui-leaflet-locate-control></aui-leaflet-locate-control>
<aui-leaflet-locate-control zoomLevel="16"></aui-leaflet-locate-control>
</div>
<div controls bottom right>
<aui-leaflet-zoom-control></aui-leaflet-zoom-control>
Expand Down
2 changes: 1 addition & 1 deletion packages/map/examples/src/map/pages/demo/demo.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public ngOnInit(): void {
<aui-leaflet-fullscreen-control></aui-leaflet-fullscreen-control>
</div>
<div controls bottom left>
<aui-leaflet-locate-control></aui-leaflet-locate-control>
<aui-leaflet-locate-control zoomLevel="16"></aui-leaflet-locate-control>
</div>
<div controls bottom right>
<aui-leaflet-zoom-control></aui-leaflet-zoom-control>
Expand Down
5 changes: 3 additions & 2 deletions packages/map/lib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Visit our [documentation site](https://acpaas-ui.digipolis.be/) for full how-to
| ----------- | ------ | -------------------------- |
| `@Input() leafletMap: LeafletMap;` | `-` | An instance of the [Leaflet Map class](https://leafletjs.com/reference-1.3.0.html#map-example). |
| `@Input() hasSidebar: boolean;` | `false` | Define if the map has a sidebar. |
| `@Input() zoomLevel: number;` | `19` | Define how far to zoom in [Leaflet Zoom Level](https://leafletjs.com/examples/zoom-levels/)

Check the [Leaflet API reference](https://leafletjs.com/reference-1.3.0.html) for Leaflet specific API's.

Expand Down Expand Up @@ -67,7 +68,7 @@ public ngOnInit(): void {
<aui-leaflet-fullscreen-control></aui-leaflet-fullscreen-control>
</div>
<div controls bottom left>
<aui-leaflet-locate-control></aui-leaflet-locate-control>
<aui-leaflet-locate-control zoomLevel="16"></aui-leaflet-locate-control>
</div>
<div controls bottom right>
<aui-leaflet-zoom-control></aui-leaflet-zoom-control>
Expand All @@ -89,7 +90,7 @@ public ngOnInit(): void {
- `zoomIn()`: Zoom in
- `zoomOut()`: Zoom out
- `toggleFullscreen()`: Toggle fullscreen
- `locate()`: Start zooming to current location
- `locate(zoomLevel)`: Start zooming to current location with an optional zoom level
- `setView(center, zoom)`: Zoom to the given center and zoom values.
- `addMarker(position, options)`: Adds a marker to the given position. (see leaflet docs)
- `addHTMLMarker`: Adds an HTML marker to the given position.
Expand Down
6 changes: 3 additions & 3 deletions packages/map/lib/src/leaflet/classes/leaflet-map.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,13 @@ describe('The leaflet map', () => {
});

it('should find the current location', () => {
map.locate();
map.locate(16);
expect(locateSpy).toHaveBeenCalled();
});

it('should zoom to the current location', () => {
map.locate();
expect(setViewSpy).toHaveBeenCalledWith(options.center, 19);
map.locate(16);
expect(setViewSpy).toHaveBeenCalledWith(options.center, 16);
});
});

Expand Down
4 changes: 2 additions & 2 deletions packages/map/lib/src/leaflet/classes/leaflet-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,13 @@ export class LeafletMap {
}

// CENTERING
locate() {
locate(zoomLevel: number) {
if (!this.locating && this.initialized) {
this.locating = true;
this.map.locate();
this.map.on('locationfound', (e: any) => {
this.locating = false;
this.map.setView(e.latlng, 19);
this.map.setView(e.latlng, zoomLevel);
this.map.off('locationfound');
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<aui-leaflet-control icon="crosshairs" (click)="map?.locate()" [disabled]="map?.locating"></aui-leaflet-control>
<aui-leaflet-control icon="crosshairs" (click)="map?.locate(zoomLevel)" [disabled]="map?.locating"></aui-leaflet-control>
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { Component } from '@angular/core';

import { Component, Input } from '@angular/core';
import { LeafletMap } from '../../../classes/leaflet-map';

@Component({
selector: 'aui-leaflet-locate-control',
templateUrl: './leaflet-locate-control.component.html',
})
export class LeafletLocateControlComponent {
map: LeafletMap;
@Input() public zoomLevel = 19;

public map: LeafletMap;
}