Sytle GeoJSON data using Mapbox GL style
Obtains basic geostatistics from GeoJSON and CVS files
npm install @geostarters/mapstyler-gl --save
import {MapStyle} from "@geostarters/mapstyler-gl/dist/mapstylergl";
const geoJSON = {
type: "FeatureCollection",
features: [
{
type: "Feature",
properties: { temp: 2 , value: "in" },
geometry: {
type: "Point",
coordinates: [2.33184814453125, 41.76926321969369],
},
},
{
type: "Feature",
properties: { temp: 3, value: "in" },
geometry: {
type: "Point",
coordinates: [2.2686767578125, 41.78014491449217],
},
},
{
type: "Feature",
properties: { temp: 8, value: "out" },
geometry: {
type: "Point",
coordinates: [2.006378173828125, 41.707266387090684],
},
},
],
};
const mapStyle = new MapStyle(geoJSON);
console.info(mapStyle.getFieldNamesColumnFromGEOJSON());
// [{name: 'temp', type: 'number'}, {name: 'value', type: 'string'}]
const layerStyle= mapStyle.createStyleLayer("name_source","name_layer","temp","cicle","#ff0000");
console.info(JSON.stringnify(layerStyle));
/*
{"id":"name_layer","style":{"id":"name_layer","source":"name_source","interactive":true,"type":"circle","minzoom":2,"maxzoom":18,"paint":{"circle-color":"#ff0000","circle-radius":["interpolate",["exponential",1],["zoom"],1,0.5,10,2]},"filter":["!=",["typeof",["get","temp"]],"null"]}}
*/
- version
-
MapStyle
- Parameters
- Examples
- getAsyncGeoJSON
- getGeomTypeFromGeoJSON
- getFieldNamesColumnFromGEOJSON
- getImplementedLayerTypes
- getFilterByDefault
- generateGeoStatisticsFromField
- createStyleLayer
- setStyleFromPreDefinedRamTemperatureHeights
- setStyleFromPreDefinedRamTemperatureInterpolateHeights
- setStyleTextSizeByFactorSize
- setStyleFromPreDefinedRamTemperatureColor
- setStylesPaintFromRanges
- setStylebyFactorHeights
- getFieldType
- getExtendFromGeoJSON
- getHaloStyleColors
- setStylePaintFromUniquesValues
- BridgeStatics
- GeoJSONStatistics
- CSVStatics
- ArrayStatics
- JsonToMap
- UtilsStatics
- Colorizator
The version of the project in use as specified in package.json
,
CHANGELOG.md
, and the GitHub release.
Type: string
A MapStyle
create a tematic style from GeoJson data, CSV o just an Array.
-
geoJSON
object GeoJSON data or URL.
const geo = new MapStyle(geojson);
Returns remote Geojson
MapStyle.getAsyncGeoJSON("https://..").then(functiion(response){})
Returns geojson this
Returns geomType from first fetaure geometry in Geojson
Returns string
Returns Array title fields from properties
Returns array
Returns object with type MapboxGL layers implemented
Returns object
Returns filter null values mapboxGL
MapStyle.getFilterByDefault("temp")
Returns filterExpression this
Return geostatistics object
-
tematicField
string
MapStyle.generateGeoStatisticsFromField("temp")
Returns geostatstics this
Create MapBox GL init style layerNamer
-
sourceName
string -
layerName
string : theMapbox gl layer ID -
keyField
string :The fieldName fromGeoJSON -
type
string : tthe geomType see getImplementedLayerTypes function -
maxzoom
number -
minzoom
number -
initColor
string -
visualization
string -
factor
number -
SorceName
string : the Mapbox gl source ID
Returns object
Return predefined style
-
tematicField
string
Returns object
Return predefined style
-
tematicField
string
Returns object
Return factor textsize
-
factorSize
number
Returns stylePre
Return predefined style
-
tematicField
string
Returns object
Returns style-color mapboxGL by Ranges
-
tematicField
string -
numRanges
number -
colorsPalette
object -
textHaloColor
boolean (optional, defaultfalse
)
MapStyle.setStylesPaintFromRanges("temp",6, "BuGn")
Returns paintStyle this
Returns style-extrude-heigths mapboxGL by factor * fieldvalue
MapStyle.setStylebyFactorHeights("temp",10)
Returns stylePre this
Returns field type number or string
-
fieldName
string
MapStyle.getFieldType("temp")
Returns string this
Returns BBOX estenc from geojson
Returns array bbox
Returns Halo colors
Returns array haloTextColors
Returns style-color mapboxGL
MapStyle.setStylePaintFromUniquesValues("comarca","#ffCC00", "#00CCff")
Returns paintStyle this
A BridgeStatics
object represents a given latitude and longitude coordinates.
-
arrayColumn
Array<number> -
lat
number Latitude, measured in degrees. -
lon
number Longitude, measured in degrees.
var ll = new BridgeStatics(42.10376, 1.84584);
Return basic stats from a GeoJson data a title field from geojson properties.
-
geoJSON
object -
keyField
string -
null
geoJSON {geoJSON:geoJSON, filedName: keyField, arrayColumn: arrayColumn}
const keyField = "temp";
const geoJSON = {"type": "FeatureCollection", "features": [{ "type": "Feature", "properties": {"temp": 2 }, "geometry": {"type": "Point", "coordinates": [2.33184814453125, 41.76926321969369] }}, { "type": "Feature", "properties": {"temp": 2 }, "geometry": {"type": "Point", "coordinates": [2.2686767578125, 41.78014491449217] }}, { "type": "Feature", "properties": {"temp": 5 }, "geometry": {"type": "Point", "coordinates": [2.2703933715820312, 41.725717979972345] }}, { "type": "Feature", "properties": {"temp": "" }, "geometry": {"type": "Point", "coordinates": [2.346096038818359, 41.74698199279457] }}, { "type": "Feature", "properties": {"temp": 1 }, "geometry": {"type": "Point", "coordinates": [2.137527465820312, 41.929868314485795] }}, { "type": "Feature", "properties": {"temp": 8 }, "geometry": {"type": "Point", "coordinates": [2.006378173828125, 41.707266387090684] }}] };
const geoSattics= new GeoJSONStatics(geoJSON, keyField)
Returns Array Unique Values
Returns array
Returns stats form RangeNum and colors Array
Returns object
Returns array from geojson properties field Used in the constructor
-
keyField
string -
GeoJSON
object -
forceNumber
boolean (optional, defaultfalse
) -
keyFiled
string -
geojson
object
Returns array this
Returns array from geojson properties field, filtered by a value
-
keyField
string -
GeoJSON
object -
keyFilter
string //Filter field -
valueFilter
string -
keyFiled
string -
geojson
object
Returns array this
Generate basic statistics from CSV array.
Sample;
const arrayCSV = [
[2, 3, 4, 3, 3],
[5, 6, 6, 4, 4],
[1, 8, 1, 5, 7]
];
const numCSVColumn = 1;
const csvStatics = new CSVStatics(arrayCSV, numCSVColumn);
Returns Array Unique Values
Returns array
Returns stats form RangeNum and colors Array
Returns object
Returns array from csv properties field Used in the constructor
Returns array this
Generate basic statistics from Array.
-
arrayColumn
Array
Sample;
const arrayColumn = [2, 3, 4, 3, 3];
const ArrayStatics = new ArrayStatics(arrayColumn);
Returns Array Unique Values
Returns array
Returns basics stats
-
decimals
number
Returns object
Returns stats form RangeNum and colors Array
Returns object
Parse information from JSON.
-
Json
object Optional
Sample;
const jsonToMap = new JsonToMap();
A UtilsStatics
object represents a.
var utils = new UtilsStatics();
A Colorizator
object represents a given latitude and longitude coordinates.
const color = new Colorizator();
Get Random color from Array
Returns string this
Get Random color hex
Returns color this
Get Chormaarray color from brewer palette
Returns color this
Get Chormaarray form two colors
Returns color this
Get Chormaarray color from brewer palette
Returns color this
Get HTML palete color
-
numberPalettes
number //number of palletes max this.maxBrewerPalettes -
numRangs
number //number of colors for each palette max this.maxBrewerPalettes
Returns color this
Generate HTML legend palete color
Returns color this
alpha 0.0.2
Reconeixement 4.0 Internacional de Creative Commons (CC-BY 4-0)
Developed by :
Institut Cartogràfic i Geològic de Catalunya (ICGC) - https://icgc.cat
Àrea d’Innovació i Estratègia Digital - Unitats Geostart