From 693c9b31ef953255f85d05cebe12a0e5984783c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois-R=C3=A9gis=20DEBOFFLES?= Date: Tue, 30 Jul 2019 16:23:17 -0600 Subject: [PATCH] fixes #37213 (#37221) Added optional `maxWidth` option to `PopupOptions` introduced in https://github.com/mapbox/mapbox-gl-js/releases/tag/v0.54.0 --- types/mapbox-gl/index.d.ts | 8 +++++++- types/mapbox-gl/mapbox-gl-tests.ts | 16 +++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/types/mapbox-gl/index.d.ts b/types/mapbox-gl/index.d.ts index 26b37616f7..fc78b68361 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 v0.53.0 +// Type definitions for Mapbox GL JS v0.54.0 // Project: https://github.com/mapbox/mapbox-gl-js // Definitions by: Dominik Bruderer // Patrick Reames @@ -658,6 +658,10 @@ declare namespace mapboxgl { setHTML(html: string): this; setDOMContent(htmlNode: Node): this; + + getMaxWidth(): string; + + setMaxWidth(maxWidth: string): this; } export interface PopupOptions { @@ -670,6 +674,8 @@ declare namespace mapboxgl { offset?: number | PointLike | { [key: string]: PointLike; }; className?: string; + + maxWidth?: string; } export interface Style { diff --git a/types/mapbox-gl/mapbox-gl-tests.ts b/types/mapbox-gl/mapbox-gl-tests.ts index 2db8e2855f..875b0720d6 100644 --- a/types/mapbox-gl/mapbox-gl-tests.ts +++ b/types/mapbox-gl/mapbox-gl-tests.ts @@ -289,10 +289,24 @@ map.removeFeatureState(featureIdentifier); /** * Popup */ -var popup = new mapboxgl.Popup({closeOnClick: false, closeButton: true, anchor: 'top-right', offset: {'top': [0,0], 'bottom': [25,-50]}, className: 'custom-class' }) +const popupOptions = { + closeOnClick: false, + closeButton: true, + anchor: 'top-right' as mapboxgl.Anchor, + offset: { + 'top': [0,0] as [number, number], + 'bottom': [25,-50] as [number, number] + }, + className: 'custom-class', + maxWidth: '400px' +}; +expectType(popupOptions); +const popup = new mapboxgl.Popup(popupOptions) .setLngLat([-50, 50]) .setHTML('

Hello World!

') + .setMaxWidth('none') .addTo(map); +popup.getMaxWidth(); /** * Add an image