@@ -37,6 +37,9 @@ export namespace CommandIDs {
37
37
38
38
export const newGeoJSONLayer = 'jupytergis:newGeoJSONLayer' ;
39
39
export const newGeoJSONSource = 'jupytergis:newGeoJSONSource' ;
40
+
41
+ export const newVectorTileLayer = 'jupytergis:newVectorTileLayer' ;
42
+
40
43
export const newVectorLayer = 'jupytergis:newVectorLayer' ;
41
44
}
42
45
@@ -125,6 +128,17 @@ export function addCommands(
125
128
execute : Private . createVectorLayer ( tracker )
126
129
} ) ;
127
130
131
+ commands . addCommand ( CommandIDs . newVectorTileLayer , {
132
+ label : trans . __ ( 'New vector tile layer' ) ,
133
+ isEnabled : ( ) => {
134
+ return tracker . currentWidget
135
+ ? tracker . currentWidget . context . model . sharedModel . editable
136
+ : false ;
137
+ } ,
138
+ iconClass : 'fa fa-vector-square' ,
139
+ execute : Private . createVectorTileLayer ( tracker )
140
+ } ) ;
141
+
128
142
commands . addCommand ( CommandIDs . newGeoJSONSource , {
129
143
label : trans . __ ( 'Add GeoJSON data from file' ) ,
130
144
isEnabled : ( ) => {
@@ -200,6 +214,71 @@ namespace Private {
200
214
} ;
201
215
}
202
216
217
+ export function createVectorTileLayer (
218
+ tracker : WidgetTracker < JupyterGISWidget >
219
+ ) {
220
+ return async ( args : any ) => {
221
+ const current = tracker . currentWidget ;
222
+
223
+ if ( ! current ) {
224
+ return ;
225
+ }
226
+
227
+ const form = {
228
+ title : 'Raster Layer parameters' ,
229
+ default : ( model : IJupyterGISModel ) => {
230
+ return {
231
+ name : 'Vector Tile Source' ,
232
+ url : 'https://planetarycomputer.microsoft.com/api/data/v1/vector/collections/ms-buildings/tilesets/global-footprints/tiles/{z}/{x}/{y}' ,
233
+ maxZoom : 24 ,
234
+ minZoom : 0
235
+ } ;
236
+ }
237
+ } ;
238
+
239
+ const dialog = new FormDialog ( {
240
+ context : current . context ,
241
+ title : form . title ,
242
+ sourceData : form . default ( current . context . model ) ,
243
+ schema : FORM_SCHEMA [ 'VectorTileSource' ] ,
244
+ syncData : ( props : IDict ) => {
245
+ const sharedModel = current . context . model . sharedModel ;
246
+ if ( ! sharedModel ) {
247
+ return ;
248
+ }
249
+
250
+ const { name, ...parameters } = props ;
251
+
252
+ const sourceId = UUID . uuid4 ( ) ;
253
+
254
+ const sourceModel : IJGISSource = {
255
+ type : 'VectorTileSource' ,
256
+ name,
257
+ parameters : {
258
+ url : parameters . url ,
259
+ minZoom : parameters . minZoom ,
260
+ maxZoom : parameters . maxZoom
261
+ }
262
+ } ;
263
+
264
+ const layerModel : IJGISLayer = {
265
+ type : 'VectorLayer' ,
266
+ parameters : {
267
+ type : 'line' ,
268
+ source : sourceId
269
+ } ,
270
+ visible : true ,
271
+ name : name + ' Layer'
272
+ } ;
273
+
274
+ sharedModel . addSource ( sourceId , sourceModel ) ;
275
+ current . context . model . addLayer ( UUID . uuid4 ( ) , layerModel ) ;
276
+ }
277
+ } ) ;
278
+ await dialog . launch ( ) ;
279
+ } ;
280
+ }
281
+
203
282
/**
204
283
* Command to create a GeoJSON source.
205
284
*
0 commit comments