diff --git a/types/mapbox-gl/index.d.ts b/types/mapbox-gl/index.d.ts index bc7426743f..f81f4019c7 100644 --- a/types/mapbox-gl/index.d.ts +++ b/types/mapbox-gl/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Mapbox GL JS 1.6 +// Type definitions for Mapbox GL JS 1.7 // Project: https://github.com/mapbox/mapbox-gl-js // Definitions by: Dominik Bruderer // Patrick Reames @@ -820,6 +820,11 @@ declare namespace mapboxgl { closeOnClick?: boolean; + /** + * @param {boolean} [options.closeOnMove=false] If `true`, the popup will closed when the map moves. + */ + closeOnMove?: boolean; + anchor?: Anchor; offset?: number | PointLike | { [key: string]: PointLike; }; @@ -864,6 +869,8 @@ declare namespace mapboxgl { [sourceName: string]: AnySourceData; } + export type PromoteIdSpecification = {[key: string]: string} | string; + export type AnySourceData = GeoJSONSourceRaw | VideoSourceRaw | ImageSourceRaw | CanvasSourceRaw | VectorSource | RasterSource | RasterDemSource export type AnySourceImpl = GeoJSONSource | VideoSource | ImageSource | CanvasSource | VectorSource | RasterSource | RasterDemSource @@ -914,6 +921,8 @@ declare namespace mapboxgl { lineMetrics?: boolean; generateId?: boolean; + + promoteId?: PromoteIdSpecification; } /** @@ -1002,6 +1011,7 @@ declare namespace mapboxgl { minzoom?: number; maxzoom?: number; attribution?: string; + promoteId?: PromoteIdSpecification; } interface RasterSource extends Source { diff --git a/types/mapbox-gl/mapbox-gl-tests.ts b/types/mapbox-gl/mapbox-gl-tests.ts index ff44c2eda6..3f40b80637 100644 --- a/types/mapbox-gl/mapbox-gl-tests.ts +++ b/types/mapbox-gl/mapbox-gl-tests.ts @@ -189,7 +189,8 @@ map.on('load', function() { [-122.49378204345702, 37.83368330777276] ] } - } + }, + promoteId: {"original": "COUNTY"} }); map.addLayer({ @@ -227,6 +228,12 @@ map.on('load', function() { } }); + // Add a vector source + map.addSource("vector-source", { + type: "vector", + promoteId: {"original": "COUNTY"} + }); + // Add a custom layer map.addLayer({ id: 'custom', @@ -365,8 +372,9 @@ map.removeFeatureState(featureIdentifier); /** * Popup */ -const popupOptions = { - closeOnClick: false, +const popupOptions: mapboxgl.PopupOptions = { + closeOnClick: false, + closeOnMove: true, closeButton: true, anchor: 'top-right' as mapboxgl.Anchor, offset: { @@ -376,7 +384,7 @@ const popupOptions = { className: 'custom-class', maxWidth: '400px' }; -expectType(popupOptions); + const popup = new mapboxgl.Popup(popupOptions) .setLngLat([-50, 50]) .trackPointer() @@ -398,7 +406,7 @@ var mapStyle = { "sources": { "mapbox": { "type": "vector", - "url": "mapbox://mapbox.mapbox-streets-v6" + "url": "mapbox://mapbox.mapbox-streets-v6" }, "overlay": { "type": "image",