MapLibre Source-Objekte

Geschrieben von am .

MapLibre Sources Specification

Source-Attribute

blob tiled media
group params geojson vector raster dem tj image video values
Config type · "geojson" | "vector" | "raster" | "raster-dem"
Config url · · · "tile-metadata-JSON-URL"
Attribution attribution · · "text"
Restrictions bounds · · · [ west°, south°, east°, north° ]
Restrictions minzoom · · · 0 … (inclusive)
Restrictions maxzoom · · 0 … 22 … (inclusive)
Datasource data · · · · · "GeoJSON-URL" | {GeoJSON-object}
Tilesource tiles · · · [ "xyz_url",]
Tilesource volatile · · · · false | true
Imagesource url · · · · · · "Image-URL"
Videosource urls · · · · · · ["Video-URLs", … ]
Format scheme · · · · "xyz" (y: △) | "tms" (y: ▽)
Format tileSize · · · · · 1 … 512 …
Format encoding · · · · · · "mapbox" | "terrarium"
Format buffer · · · · · · 0 … 128 … 512
Features promoteId · · · · · "property_name" | { "source_layer": "property_name" }
Features filter · · · · · · [ filter_expression ]
Features generateId · · · · · · false | true
Punktfeatures cluster · · · · · · false | true
Punktfeatures clusterMinPoints · · · · · · 2
Punktfeatures clusterRadius · · · · · · 0 … 50 … 512
Punktfeatures clusterMaxZoom · · · · · · 0 … maxzoom_minus_one
Punktfeatures clusterProperties · · · · · · {"property_name": [ "operator", map_expression ]}
Line-Features lineMetrics · · · · · · false | true
Line-Features tolerance · · · · · · 0 … 0.375
Mediafeatures coordinates · · · · · [ [lng1,lon1], [lng2,lat2], [lng3,lat3], [lng4,lat4] ]
~ links oben, rechts oben, rechts unten, links unten

Source-Instanzmethoden.

Map:
  • Füge der Karte ein Source-Objekt hinzu:

    map.addSource('id', {attributes} );
  • Entnehme der Karte ein bestimmtes Source-Objekt:

    map.getSource('id').sourceMemberMethod(…);
  • Entferne ein bestimmtes Source-Objekt:

    map.removeSource('id');
GeoJSON-Source:
  • Ändere den Inhalt des Source-Objektes:

    geojsonsource.setData( 'geojson_url' | {geojson_object} );
  • Bestimme den Zoom, bei dem ein Cluster aufgelöst wird:

    geojsonsource.getClusterExpansionZoom( 'cluster_id', callback );

    Das Callback wird aufgerufen als:

    callback( error, zoom )
  • Bestimme die Elemente eines Clusters auf der nächsten Zoomstufe:

    geojsonsource.getClusterChildren( 'cluster_id', callback );

    Das Callback wird aufgerufen als:

    callback( error, [feature, …] )
  • Bestimme alle Punkte, die zu einem Cluster gehören:

    geojsonsource.getClusterLeaves( 'cluster_id', limit, offset, callback );

    Das Callback wird aufgerufen als:

    callback( error, [feature, …] )
Video-Source:
  • Bestimme das HTML-<video>-Element:

    videosource.getVideo() → <video>;
  • Start/Stopp:

    videosource.play();
    videosource.stop();
  • Aktualisiere die Position:

    videosource.setCoordinates([ [lng1,lat1], [lng2,lat2], [lng3,lat3], [lng4,lat4] ]);
Image-Source:
  • Aktualisiere die Position:

    imagesource.setCoordinates([ [lng1,lat1], [lng2,lat2], [lng3,lat3], [lng4,lat4] ]);
  • Aktualisiere das Bild:

    imagesource.updateImage({'url':'image_url', 'coordinates':[ pt1, pt2, pt2, pt3 ]});

TileJSON-Spezifikation

Mapbox TileJSON 3.0.0

· tilejson string (#.#.#) 3.0.0
Name · name string null human readable name of tileset
Name · description string null human readable description of tileset
Name · legend string null layer legend
Version · version string (#.#.#) 1.0.0 major.minor.patch
Attribution attribution string null data attribution
Datasource tiles string[] xyz-tile urls
Datasource scheme string "xyz" "xyz" | "tms"
Datasource · data string[] [] overlay GeoJSON urls
Grid · grids string[] [] grid json urls
Grid · template string null grid data formatting
Restrictions bounds number[4] 180/85 [west, south, east, north]
Restrictions minzoom number 0 0 … 30
Restrictions maxzoom number 30 0 … 30
Display · center number[2…3] null lng, lat, [zoom]
Display · fillzoom number null source zoom for overzoom
Layers · vector_layers object[] layer specification
Layers · id string layer id
Layers · fields object name:description of fields in this layer
Layers · description string null human readable description
Layers · minzoom number null layer contains data from this zoom
Layers · maxzoom number null layer contains data upto this zoom