1.6.0 • Published 9 months ago

@musasutisna/vue-gis v1.6.0

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

VueGIS is based on Vue 3 with composition style codes and compatible with arcgis.js core library version 4.25

Getting started

Lets install vue-gis with npm

npm install --save @musasutisna/vue-gis

after install completed next load map into your vue component

<script setup>
import { VueGIS } from '@musasutisna/vue-gis'

function mapReady() {
  // map is ready
}
</script>

<template>
  <div style="position: fixed;top: 0;right: 0;bottom: 0;left: 0;width: 100%;height: 100%;">
    <VueGIS @ready="mapReady" />
  </div>
</template>

Configuration

All configuration we setup inside a file json, all files is located by default at src/public in your vue directory. Create a new directory with name map to collected all setting files, in other hand all files located can be customize by override with these config

window.config = {
  MAP_URL_CONFIG: '/map',
  MAP_URL_CONFIG_FILE: '/config.json'
  MAP_URL_CATEGORY_FILE: '/category.json'
  MAP_URL_GROUP_FILE: '/group.json'
  MAP_URL_BASEMAP_FILE: '/basemap.json'
  MAP_URL_LAYER_FILE: '/layer.json'
  MAP_URL_LEGEND_FILE: '/legend.json'
}

How to config (config.json)

Configure the global properties of the library and manage the map display settings.

{
  "EsriConfig": {
    // available esri config properties
  },
  "MapView": {
    "zoom": 5,
    "scale": 18000000,
    "center": [113.9213, -0.7893]
  }
}
NameTypeDescription
EsriConfigObjecthttps://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#properties-summary
MapView.zoomIntegerZoom level of map.
MapView.scaleIntegerScale level of map.
MapView.centerArrayCentral point of map.

All configurations will be automatically set to EsriConfig and pre-processed with custom parameters. However, some properties will be handled by a handler and must match the specified format.

  • request interceptors
{
  "request": {
    "interceptors": [
      {
        "urls",
        "headers": {
          // all header will be pass to request header
        }
      }
    ]
  }
}

Categorizing Layer (category.js)

Make a base category for all our layer collection to help our developed all displayed layer make easier controled like toggle or removed.

NameTypeDescription
idIntegerUnique id of category.
nameStringName of category.
titleStringTitle of category.
orderIntegerOrdering category number.
enableBooleanSet true to make category readable and false to skip category.

Grouping Layer (group.js)

Make a base group for all our layer collection to help our developed all displayed layer make easier controled like toggle or removed.

NameTypeDescription
idIntegerUnique id of group.
nameStringName of group.
titleStringTitle of group.
orderIntegerOrdering group number.
enableBooleanSet true to make group readable and false to skip group.
iconStringUrl to image icon of group.

How to setup basemap (basemap.json)

A basemap is a background map layer that provides context and reference information for the primary data being displayed on a map, these a example free basemap hosted by ArcGIS

[
  {
    "id": 1,
    "enable": true,
    "default": false,
    "title": "Satellite",
    "type": "BasemapId",
    "BasemapId": "satellite"
  },
  {
    "id": 2,
    "enable": true,
    "default": false,
    "title": "Hybrid",
    "type": "BasemapId",
    "BasemapId": "hybrid"
  },
  {
    "id": 3,
    "enable": true,
    "default": false,
    "title": "Oceans",
    "type": "BasemapId",
    "BasemapId": "oceans"
  },
  {
    "id": 4,
    "enable": true,
    "default": true,
    "title": "OSM",
    "type": "BasemapId",
    "BasemapId": "oceans"
  },
  {
    "id": 5,
    "enable": true,
    "default": false,
    "title": "Terrain",
    "type": "BasemapId",
    "BasemapId": "terrain"
  },
  {
    "id": 6,
    "enable": true,
    "default": false,
    "title": "Dark Gray",
    "type": "BasemapId",
    "BasemapId": "dark-gray-vector"
  },
  {
    "id": 7,
    "enable": true,
    "default": false,
    "title": "Gray",
    "type": "BasemapId",
    "BasemapId": "gray-vector"
  },
  {
    "id": 8,
    "enable": true,
    "default": false,
    "title": "Streets",
    "type": "BasemapId",
    "BasemapId": "streets-vector"
  },
  {
    "id": 9,
    "enable": true,
    "default": false,
    "title": "Streets Night",
    "type": "BasemapId",
    "BasemapId": "streets-night-vector"
  },
  {
    "id": 10,
    "enable": true,
    "default": false,
    "title": "Streets Navigation",
    "type": "BasemapId",
    "BasemapId": "streets-navigation-vector"
  },
  {
    "id": 11,
    "enable": true,
    "default": false,
    "title": "Topo",
    "type": "BasemapId",
    "BasemapId": "topo-vector"
  },
  {
    "id": 12,
    "enable": true,
    "default": false,
    "title": "Streets Relief",
    "type": "BasemapId",
    "BasemapId": "streets-relief-vector"
  }
]

Every item in basemap have a structure with this description

NameTypeDescription
idIntegerUnique id of basemap layer.
enableBooleanSet true to make basemap readable and false to skip basemap.
defaultBooleanSet true to make a basemap as active layer on initial load.
titleStringThe title of basemap.
typeStringType of basemap (BasemapId, WMTSLayer).
BasemapIdStringhttps://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#basemap
WMTSLayerObjecthttps://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMTSLayer.html#properties-summary

How to setup layer (layer.json)

A layer is a distinct collection of geographic data that is displayed and managed together. Each layer represents a specific type of data, such as points, lines, polygons, or raster images, and can be visualized on top of a basemap or other layers to provide a comprehensive view of spatial information. A configuration layer can be setup with these structure.

NameTypeDescription
idIntegerunique id of layer.
categoryStringCategory of layer, selected one available in category.json.
groupStringGroup of layer, selected one available in group.json.
enableBooleanSet true to make layer readable and false to skip layer.
showBooleanSet true to make a layer initial load.
titleStringThe title of layer.
typeStringType of layer (GeojsonLayer, WMSLayer, MapImageLayer).
contentStringType shown by layer (image, line, point).
permissionArrayThe list permission allowed to enable the layer.
zindexIntegerThe number of zindex layer.
main_orderIntegerThe number of ordering main layer.
category_orderIntegerThe number of ordering category layer.
group_orderIntegerThe number of ordering group layer.
GeojsonLayerObjecthttps://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GeoJSONLayer.html
WMTSLayerObjecthttps://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMTSLayer.html
MapImageLayerObjecthttps://developers.arcgis.com/javascript/latest/api-reference/esri-layers-MapImageLayer.html
GraphicsLayerObjecthttps://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GraphicsLayer.html

How to setup legend (legend.json)

A legend is a key that explains the symbols, colors, and patterns used on a map. It helps users understand what the various map elements represent, such as different types of roads, land use, water bodies, or elevation levels. Feel free to customize the legend format in these files.

NameTypeDescription
titleStringThe title of legend.
subArrayCollection of detailed legend items.
sub[].nameStringName of the legend item.
sub[].symbolStringURL to the symbol image.
sub[].descStringDetailed description of the legend item.

Custom parameters

Pre-processing custom parameters with supplied data and from executed method.

"customParameters": {
  "property_one": {
    "@lib": "toString",
    "@params": [{"one":1,"two":2,"there":3}, ":", ";"]
  },
  "propety_two": {
    "token": {
      "@lib": "sessionStorage",
      "@params": ["token"]
    }
  },
  "property_there": "there"
  "property_four": "four",
  "property_five": { "$": "five" }
}

will produces

"customParameters": {
  "property_one": "one=1;two=2;there=3",
  "property_two": "token saved in session storage",
  "property_there": "there",
  "property_four": "four",
  "property_five": 5
}

that format "@lib" is fill with method name availble on libs and "@params" is the arguments will be pass into method and "$" to access custom data supplied by generate parameter and all property without format will be normaled values.

Custom parameters @lib

The lib is have reserved method could not be used "execute", but you can use following method in our custom parameter

@lib: localStorage

Get a data from localStorage with key

Return: String

Parameters

NameTypeDescription
NameStringThe key will be get on localStorage.

@lib: sessionStorage

Get a data from sessionStorage with key

Return: String

Parameters

NameTypeDescription
NameStringThe key will be get on sessionStorage.

@lib: toString

Convert a object into string, and we could add assign and sparator

Return: String

Parameters

NameTypeDescription
ItemsArray | ObjectItems will be convert into string.
PrefixString | BooleanPrefix value item.
SuffixString | BooleanSuffix value item.
AssignBoolean | StringAssign value items with assign to index.
SparatorBoolean | StringSparator to chain every item.
"customParameters": {
  "property": {
    "@lib": "toString",
    "@params": [
      { "one": 1, "two": 2, "there": 3},
      "'",
      "'",
      "=",
      ";"
    ]
  }
}

@lib: cast

Type casting of item

Return: Mixed

Parameters

NameTypeDescription
ItemMixedItem will be type casting.
TypeStringThe return type of item we want.

@lib: moment

moment.js is a powerful JavaScript library used for parsing, validating, manipulating, and formatting dates. It simplifies working with dates in JavaScript by providing a consistent and intuitive API. Here’s a brief guide to interfacing with moment.js for common date operations.

Return: Mixed

Parameters

NameTypeDescription
DatetimeString | BooleanThe Datetime parameter will be passed to moment().
ItemsObjectA collection of moment methods to be called.
"customParameters": {
  "date": {
    "@lib": "moment",
    "@params": [
      false,
      {
        "utc": false,
        "format": ["YYYY-MM-DD hh:mm:ss"]
      }
    ]
  }
}

@lib: replace

Replace placeholders in a string using key-value pairs from an object by utilizing the replace method with the regular expression /{(.*?)}/g.

Return: String

Parameters

NameTypeDescription
subjectStringThe subject string will be replaced with key-value pairs.
haystackObjectA collection of haystacks contains key-value pairs.
"customParameters": {
  "CQL_FILTER": {
    "@lib": "replace",
    "@params": [
      "created_date DURING ('{start}', '{end}') AND status = '{status}'",
      {
        "start": { "$": "startDatetime" },
        "end": { "$": "endDatetime" },
        "status": "active"
      }
    ]
  }
}
1.6.0

9 months ago

1.5.0

9 months ago

1.4.1

10 months ago

1.4.0

10 months ago

1.3.0

10 months ago

1.2.0

11 months ago

1.1.1

11 months ago

1.1.0

11 months ago

1.0.2

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago

0.0.1

11 months ago

0.0.2

11 months ago

0.0.0

11 months ago