Added optional `maxWidth` option to `PopupOptions` introduced in https://github.com/mapbox/mapbox-gl-js/releases/tag/v0.54.0
This commit is contained in:
François-Régis DEBOFFLES
2019-07-30 16:23:17 -06:00
committed by Jesse Trinity
parent f5a50ceae9
commit 693c9b31ef
2 changed files with 22 additions and 2 deletions

View File

@@ -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 <https://github.com/dobrud>
// Patrick Reames <https://github.com/patrickr>
@@ -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 {

View File

@@ -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<mapboxgl.PopupOptions>(popupOptions);
const popup = new mapboxgl.Popup(popupOptions)
.setLngLat([-50, 50])
.setHTML('<h1>Hello World!</h1>')
.setMaxWidth('none')
.addTo(map);
popup.getMaxWidth();
/**
* Add an image