Skip to content

Commit 477d058

Browse files
ADD expose some controls (#26)
1 parent aac8b82 commit 477d058

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+1318
-423
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## [v1.0.6](https://github.com/maptiler/maptiler-sdk-js/releases/tag/v1.0.6)
4+
- Now exposing `MaptilerGeolocateControl` for external initialization if needed
5+
- Now exposing `MaptilerTerrain` for external initialization if needed
6+
37
## [v1.0.5](https://github.com/maptiler/maptiler-sdk-js/releases/tag/v1.0.5)
48
- Terrain elevation is now using MapTiler's `terrain-rgb-v2`
59

demos/maptiler-sdk.umd.js

Lines changed: 10 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/maptiler-sdk.d.ts

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as maplibre_gl from 'maplibre-gl';
2-
import maplibre_gl__default, { MapOptions as MapOptions$1, StyleSpecification, ControlPosition, StyleOptions } from 'maplibre-gl';
2+
import maplibre_gl__default, { MapOptions as MapOptions$1, StyleSpecification, ControlPosition, StyleOptions, LogoOptions as LogoOptions$1 } from 'maplibre-gl';
33
export * from 'maplibre-gl';
44
import * as _mapbox_mapbox_gl_supported from '@mapbox/mapbox-gl-supported';
55
import { ReferenceMapStyle, MapStyleVariant, FetchFunction } from '@maptiler/client';
@@ -254,6 +254,57 @@ declare class Map extends maplibre_gl__default.Map {
254254
getCameraHash(): string;
255255
}
256256

257+
declare const GeolocateControl$1: typeof maplibre_gl.GeolocateControl;
258+
/**
259+
* The MaptilerGeolocateControl is an extension of the original GeolocateControl
260+
* with a few changes. In this version, the active mode persists as long as the
261+
* location is still centered. This means it's robust to rotation, pitch and zoom.
262+
*
263+
*/
264+
declare class MaptilerGeolocateControl extends GeolocateControl$1 {
265+
private lastUpdatedCenter;
266+
/**
267+
* Update the camera location to center on the current position
268+
*
269+
* @param {Position} position the Geolocation API Position
270+
* @private
271+
*/
272+
_updateCamera(position: GeolocationPosition): void;
273+
_setupUI(supported: boolean): void;
274+
_updateCircleRadius(): void;
275+
_onZoom(): void;
276+
}
277+
278+
declare type LogoOptions = LogoOptions$1 & {
279+
logoURL?: string;
280+
linkURL?: string;
281+
};
282+
/**
283+
* This LogoControl extends the MapLibre LogoControl but instead can use any image URL and
284+
* any link URL. By default this is using MapTiler logo and URL.
285+
*/
286+
declare class MaptilerLogoControl extends maplibre_gl__default.LogoControl {
287+
private logoURL;
288+
private linkURL;
289+
constructor(options?: LogoOptions);
290+
onAdd(map: Map): HTMLElement;
291+
}
292+
293+
/**
294+
* A `MaptilerTerrainControl` control adds a button to turn terrain on and off
295+
* by triggering the terrain logic that is already deployed in the Map object.
296+
*/
297+
declare class MaptilerTerrainControl implements maplibregl.IControl {
298+
_map: Map;
299+
_container: HTMLElement;
300+
_terrainButton: HTMLButtonElement;
301+
constructor();
302+
onAdd(map: Map): HTMLElement;
303+
onRemove(): void;
304+
_toggleTerrain(): void;
305+
_updateTerrainIcon(): void;
306+
}
307+
257308
/**
258309
* This is TypeScript rewrite of the Point class to use instead of the version imported in MapLibre.
259310
* It also uses a class instead of prototypes.
@@ -528,4 +579,4 @@ declare const workerUrl: string;
528579
declare const addProtocol: (customProtocol: string, loadFn: (requestParameters: maplibre_gl.RequestParameters, callback: maplibre_gl.ResponseCallback<any>) => maplibre_gl.Cancelable) => void;
529580
declare const removeProtocol: (customProtocol: string) => void;
530581

531-
export { AJAXError, AttributionControl, CanvasSource, Evented, FullscreenControl, GeoJSONSource, GeolocateControl, GeolocationType, ImageSource, Language, LanguageKey, LanguageString, LngLat, LngLatBounds, LogoControl, Map, MapOptions, Marker, Matrix2, MercatorCoordinate, NavigationControl, Point, Popup, RasterDEMTileSource, RasterTileSource, ScaleControl, SdkConfig, Style, TerrainControl, Unit, VectorTileSource, VideoSource, addProtocol, clearPrewarmedResources, clearStorage, config, getRTLTextPluginStatus, maxParallelImageRequests, prewarm, removeProtocol, setRTLTextPlugin, supported, version, workerCount, workerUrl };
582+
export { AJAXError, AttributionControl, CanvasSource, Evented, FullscreenControl, GeoJSONSource, GeolocateControl, GeolocationType, ImageSource, Language, LanguageKey, LanguageString, LngLat, LngLatBounds, LogoControl, Map, MapOptions, MaptilerGeolocateControl, MaptilerLogoControl, MaptilerTerrainControl, Marker, Matrix2, MercatorCoordinate, NavigationControl, Point, Popup, RasterDEMTileSource, RasterTileSource, ScaleControl, SdkConfig, Style, TerrainControl, Unit, VectorTileSource, VideoSource, addProtocol, clearPrewarmedResources, clearStorage, config, getRTLTextPluginStatus, maxParallelImageRequests, prewarm, removeProtocol, setRTLTextPlugin, supported, version, workerCount, workerUrl };

dist/maptiler-sdk.min.mjs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

dist/maptiler-sdk.mjs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ const defaults = {
142142
};
143143
Object.freeze(defaults);
144144

145-
class CustomLogoControl extends maplibregl__default.LogoControl {
145+
class MaptilerLogoControl extends maplibregl__default.LogoControl {
146146
constructor(options = {}) {
147147
var _a, _b;
148148
super(options);
@@ -235,7 +235,7 @@ function styleToStyle(style) {
235235
return style;
236236
}
237237

238-
class TerrainControl$1 {
238+
class MaptilerTerrainControl {
239239
constructor() {
240240
bindAll(["_toggleTerrain", "_updateTerrainIcon"], this);
241241
}
@@ -349,7 +349,7 @@ var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
349349
const GeolocateControl$1 = maplibregl__default.GeolocateControl;
350350
const Marker$1 = maplibregl__default.Marker;
351351
const LngLat$1 = maplibregl__default.LngLat;
352-
class CustomGeolocateControl extends GeolocateControl$1 {
352+
class MaptilerGeolocateControl extends GeolocateControl$1 {
353353
constructor() {
354354
super(...arguments);
355355
this.lastUpdatedCenter = new LngLat$1(0, 0);
@@ -665,14 +665,14 @@ class Map extends maplibregl__default.Map {
665665
if ("logo" in tileJsonContent && tileJsonContent.logo) {
666666
const logoURL = tileJsonContent.logo;
667667
this.addControl(
668-
new CustomLogoControl({ logoURL }),
668+
new MaptilerLogoControl({ logoURL }),
669669
options.logoPosition
670670
);
671671
if (options.attributionControl === false) {
672672
this.addControl(new maplibregl__default.AttributionControl(options));
673673
}
674674
} else if (options.maptilerLogo) {
675-
this.addControl(new CustomLogoControl(), options.logoPosition);
675+
this.addControl(new MaptilerLogoControl(), options.logoPosition);
676676
}
677677
if (options.scaleControl) {
678678
const position = options.scaleControl === true || options.scaleControl === void 0 ? "bottom-right" : options.scaleControl;
@@ -689,7 +689,7 @@ class Map extends maplibregl__default.Map {
689689
if (options.geolocateControl !== false) {
690690
const position = options.geolocateControl === true || options.geolocateControl === void 0 ? "top-right" : options.geolocateControl;
691691
this.addControl(
692-
new CustomGeolocateControl({
692+
new MaptilerGeolocateControl({
693693
positionOptions: {
694694
enableHighAccuracy: true,
695695
maximumAge: 0,
@@ -707,7 +707,7 @@ class Map extends maplibregl__default.Map {
707707
}
708708
if (options.terrainControl) {
709709
const position = options.terrainControl === true || options.terrainControl === void 0 ? "top-right" : options.terrainControl;
710-
this.addControl(new TerrainControl$1(), position);
710+
this.addControl(new MaptilerTerrainControl(), position);
711711
}
712712
if (options.fullscreenControl) {
713713
const position = options.fullscreenControl === true || options.fullscreenControl === void 0 ? "top-right" : options.fullscreenControl;
@@ -1146,5 +1146,5 @@ const {
11461146
removeProtocol
11471147
} = maplibregl__default;
11481148

1149-
export { AJAXError, AttributionControl, CanvasSource, Evented, FullscreenControl, GeoJSONSource, GeolocateControl, GeolocationType, ImageSource, Language, LngLat, LngLatBounds, LogoControl, Map, Marker, MercatorCoordinate, NavigationControl, Point, Popup, RasterDEMTileSource, RasterTileSource, ScaleControl, SdkConfig, Style, TerrainControl, VectorTileSource, VideoSource, addProtocol, clearPrewarmedResources, clearStorage, config, getRTLTextPluginStatus, maxParallelImageRequests, prewarm, removeProtocol, setRTLTextPlugin, supported, version, workerCount, workerUrl };
1149+
export { AJAXError, AttributionControl, CanvasSource, Evented, FullscreenControl, GeoJSONSource, GeolocateControl, GeolocationType, ImageSource, Language, LngLat, LngLatBounds, LogoControl, Map, MaptilerGeolocateControl, MaptilerLogoControl, MaptilerTerrainControl, Marker, MercatorCoordinate, NavigationControl, Point, Popup, RasterDEMTileSource, RasterTileSource, ScaleControl, SdkConfig, Style, TerrainControl, VectorTileSource, VideoSource, addProtocol, clearPrewarmedResources, clearStorage, config, getRTLTextPluginStatus, maxParallelImageRequests, prewarm, removeProtocol, setRTLTextPlugin, supported, version, workerCount, workerUrl };
11501150
//# sourceMappingURL=maptiler-sdk.mjs.map

dist/maptiler-sdk.mjs.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/maptiler-sdk.umd.js

Lines changed: 10 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/maptiler-sdk.umd.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/maptiler-sdk.umd.min.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/assets/search.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)