mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 20:40:20 +00:00
Update mapbox-gl to v0.53.0 (#37145)
* Update mapbox-gl to v0.53.0 * Added tests * Fixed removeFeatureState argument type * Added missing semicolons * Added extra test case, clean up * Removed import added by editor which broke tests
This commit is contained in:
committed by
Jesse Trinity
parent
47b7924a7d
commit
71b643e240
Vendored
+19
-3
@@ -1,9 +1,10 @@
|
||||
// Type definitions for Mapbox GL JS v0.51.0
|
||||
// Type definitions for Mapbox GL JS v0.53.0
|
||||
// Project: https://github.com/mapbox/mapbox-gl-js
|
||||
// Definitions by: Dominik Bruderer <https://github.com/dobrud>
|
||||
// Patrick Reames <https://github.com/patrickr>
|
||||
// Karl-Aksel Puulmann <https://github.com/macobo>
|
||||
// Dmytro Gokun <https://github.com/dmytro-gokun>
|
||||
// Liam Clarke <https://github.com/LiamAttClarke>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 3.0
|
||||
|
||||
@@ -15,6 +16,7 @@ export as namespace mapboxgl;
|
||||
declare namespace mapboxgl {
|
||||
let accessToken: string;
|
||||
let version: string;
|
||||
let baseApiUrl: string;
|
||||
|
||||
export function supported(options?: { failIfMajorPerformanceCaveat?: boolean }): boolean;
|
||||
|
||||
@@ -148,9 +150,11 @@ declare namespace mapboxgl {
|
||||
|
||||
getLight(): mapboxgl.Light;
|
||||
|
||||
setFeatureState(feature: { source: string, sourceLayer?: string, id: string | number } | mapboxgl.MapboxGeoJSONFeature, state: { [key: string]: any }): void;
|
||||
setFeatureState(feature: FeatureIdentifier | mapboxgl.MapboxGeoJSONFeature, state: { [key: string]: any }): void;
|
||||
|
||||
getFeatureState(feature: { source: string, sourceLayer?: string, id: string | number } | mapboxgl.MapboxGeoJSONFeature): { [key: string]: any };
|
||||
getFeatureState(feature: FeatureIdentifier | mapboxgl.MapboxGeoJSONFeature): { [key: string]: any };
|
||||
|
||||
removeFeatureState(target: FeatureIdentifier | mapboxgl.MapboxGeoJSONFeature, key?: string): void;
|
||||
|
||||
getContainer(): HTMLElement;
|
||||
|
||||
@@ -254,6 +258,9 @@ declare namespace mapboxgl {
|
||||
/** Snap to north threshold in degrees. */
|
||||
bearingSnap?: number;
|
||||
|
||||
/** The initial bounds of the map. If bounds is specified, it overrides center and zoom constructor options. */
|
||||
bounds?: LngLatBoundsLike;
|
||||
|
||||
/** If true, enable the "box zoom" interaction (see BoxZoomHandler) */
|
||||
boxZoom?: boolean;
|
||||
|
||||
@@ -317,6 +324,9 @@ declare namespace mapboxgl {
|
||||
/** If true, map creation will fail if the implementation determines that the performance of the created WebGL context would be dramatically lower than expected. */
|
||||
failIfMajorPerformanceCaveat?: boolean;
|
||||
|
||||
/** A fitBounds options object to use only when setting the bounds option. */
|
||||
fitBoundsOptions?: FitBoundsOptions;
|
||||
|
||||
/** If false, no mouse, touch, or keyboard listeners are attached to the map, so it will not respond to input */
|
||||
interactive?: boolean;
|
||||
|
||||
@@ -454,6 +464,12 @@ declare namespace mapboxgl {
|
||||
right: number;
|
||||
}
|
||||
|
||||
export interface FeatureIdentifier {
|
||||
id?: string | number,
|
||||
source: string
|
||||
sourceLayer?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* BoxZoomHandler
|
||||
*/
|
||||
|
||||
@@ -7,6 +7,10 @@ import mapboxgl = require('.');
|
||||
*/
|
||||
mapboxgl.accessToken = 'foo';
|
||||
|
||||
/**
|
||||
* Set Base API URL
|
||||
*/
|
||||
mapboxgl.baseApiUrl = 'https://example.com';
|
||||
|
||||
/**
|
||||
* Display a Map
|
||||
@@ -29,11 +33,36 @@ let map = new mapboxgl.Map({
|
||||
dragPan: true,
|
||||
});
|
||||
|
||||
/**
|
||||
* Initialize map with bounds
|
||||
*/
|
||||
expectType<mapboxgl.MapboxOptions>({
|
||||
container: 'map',
|
||||
bounds: new mapboxgl.LngLatBounds([-100, -90, 100, 90]),
|
||||
fitBoundsOptions: {
|
||||
padding: 0,
|
||||
offset: new mapboxgl.Point(0, 0),
|
||||
linear: true,
|
||||
maxZoom: 22,
|
||||
easing: time => time
|
||||
}
|
||||
});
|
||||
expectType<mapboxgl.MapboxOptions>({
|
||||
container: 'map',
|
||||
bounds: [[-100, -90], [100, 90]],
|
||||
fitBoundsOptions: {
|
||||
offset: [0, 0]
|
||||
}
|
||||
});
|
||||
expectType<mapboxgl.MapboxOptions>({
|
||||
container: 'map',
|
||||
bounds: [-100, -90, 100, 90]
|
||||
});
|
||||
|
||||
/**
|
||||
* Create and style marker clusters
|
||||
*/
|
||||
map.on('load', function(){
|
||||
map.on('load', function() {
|
||||
|
||||
// Add a new source from our GeoJSON data and set the
|
||||
// 'cluster' option to true.
|
||||
@@ -55,7 +84,7 @@ map.on('load', function(){
|
||||
}
|
||||
});
|
||||
|
||||
var layers: [number, string][] = [
|
||||
var layers: [number, string][] = [
|
||||
[150, '#f28cb1'],
|
||||
[20, '#f1f075'],
|
||||
[0, '#51bbd6']
|
||||
@@ -93,9 +122,9 @@ map.on('load', function(){
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Add a GeoJSON line
|
||||
*/
|
||||
/**
|
||||
* Add a GeoJSON line
|
||||
*/
|
||||
map.addSource("route", {
|
||||
"type": "geojson",
|
||||
"data": {
|
||||
@@ -234,14 +263,28 @@ map.addSource('radar', {
|
||||
type: 'raster',
|
||||
tiles: ['https://nowcoast.noaa.gov/arcgis/services/nowcoast/radar_meteo_imagery_nexrad_time/MapServer/WmsServer?bbox={bbox-epsg-3857}&service=WMS&request=GetMap&version=1.3.0&layers=1&styles=&format=image/png&transparent=true&height=256&width=256&crs=EPSG:3857'],
|
||||
tileSize: 256
|
||||
})
|
||||
});
|
||||
|
||||
map.addLayer({
|
||||
id: 'radar',
|
||||
type: 'raster',
|
||||
source: 'radar',
|
||||
paint: {}
|
||||
})
|
||||
});
|
||||
|
||||
/**
|
||||
* Manipulate feature state
|
||||
*/
|
||||
let featureIdentifier = {
|
||||
id: 1337,
|
||||
source: 'source-id',
|
||||
sourceLayer: 'liam-was-here'
|
||||
};
|
||||
expectType<mapboxgl.FeatureIdentifier>(featureIdentifier);
|
||||
map.setFeatureState(featureIdentifier, { someState: true, someOtherState: 123 });
|
||||
map.getFeatureState(featureIdentifier);
|
||||
map.removeFeatureState(featureIdentifier, 'someState');
|
||||
map.removeFeatureState(featureIdentifier);
|
||||
|
||||
/**
|
||||
* Popup
|
||||
@@ -412,9 +455,9 @@ marker.remove();
|
||||
/*
|
||||
* LngLatBounds
|
||||
*/
|
||||
let bool:boolean
|
||||
let bounds = new mapboxgl.LngLatBounds()
|
||||
bool = bounds.isEmpty()
|
||||
let bool:boolean;
|
||||
let bounds = new mapboxgl.LngLatBounds();
|
||||
bool = bounds.isEmpty();
|
||||
/*
|
||||
* AttributionControl
|
||||
*/
|
||||
@@ -533,7 +576,7 @@ let cameraForBoundsOpts: mapboxgl.CameraForBoundsOptions = {
|
||||
maxZoom: 10,
|
||||
padding,
|
||||
...cameraOpts,
|
||||
}
|
||||
};
|
||||
|
||||
expectType<mapboxgl.CameraForBoundsResult | undefined>(map.cameraForBounds(lnglatboundslike));
|
||||
expectType<mapboxgl.CameraForBoundsResult | undefined>(map.cameraForBounds(lnglatboundslike, cameraForBoundsOpts));
|
||||
|
||||
Reference in New Issue
Block a user