-
add(obj)
-
Adds a layer.
Either pass in a layer object or a data set. In the later case, an
OsmDataLayer is
automatically created.
Parameters:
Name |
Type |
Description |
obj |
Layer
|
DataSet
|
a layer to add,
or a dataset. Ignored if null or undefined. |
- Source:
-
Returns:
the added layer
-
Type
-
Layer
Example
import layers from 'josm/layers'
const OsmDataLayer = Java.type('org.openstreetmap.josm.gui.layer.OsmDataLayer')
const DataSet = Java.type('org.openstreetmap.josm.data.osm.DataSet')
const dataLayer = new OsmDataLayer(new DataSet(), null, null);
// add a layer ...
layers.add(dataLayer)
// or add a dataset, which will create a data layer
const ds = new DataSet()
layer.add(ds)
-
addDataLayer(args)
-
Creates and adds a new data layer. The new layer becomes the new edit
layer.
Signatures
addDataLayer()
- create data layer with a new dataset and default name
addDataLayer(ds)
- create data layer with dataset ds and default name
addDataLayer(name)
- create data layer with a new dataset and name
name
addDataLayer({name: ..., ds: ...})
- create data layer with a new dataset and name
name
Parameters:
Name |
Type |
Description |
args |
string
|
DataSet
|
object
|
see description |
- Source:
-
Returns:
the added layer
-
Type
-
OsmDataLayer
Example
import josm from 'josm'
const DataSet = Java.type('org.openstreetmap.josm.data.osm.DataSet')
// creates a new data layer
const l1 = josm.layers.addDataLayer()
// creates a new data layer with name 'test'
const l2 = josm.layers.addDataLayer('test')
// creates a new data layer for the dataset ds
const ds = new DataSet()
const l3 = josm.layers.addDataLayer(ds)
-
get(key)
-
Replies one of the layers given a key.
- If
key
is a number, replies the layer with index key, or
undefined, if no layer for this index exists.
- If
key
is a string, replies the first layer whose name
is identical to key (case insensitive, without leading/trailing
whitespace), or undefined, if no layer with such a name exists.
Parameters:
Name |
Type |
Description |
key |
number
|
string
|
the key to retrieve the layer |
- Source:
-
Returns:
-
Type
-
Layer
Example
import layers from 'josm/layers'
// get the first layer
const layer1 = layers.get(0)
// get the first layer with name "data layer"
const layer2 = layers.get('data layer')
-
has(layer)
-
Checks whether layer
is a currently registered layer.
Parameters:
Name |
Type |
Description |
layer |
Layer
|
string
|
number
|
a layer,
a layer name, or a layer index |
- Source:
-
Returns:
true, if the layer or at least one layer with the given name exists.
False, otherwise.
-
Type
-
boolean
Example
import layers from 'josm/layers'
// is there a layer with name "my layer"?
let b = layers.has('my layer')
// is there a layer at index position 2
b = layers.has(2)
// is there a specific layer?
let l = layers.get(0)
b = layers.has(l)
-
remove(key)
-
Removes a layer with the given key.
- If
key
is a Number
, removes the layer with
the index key. If the index doesn't isn't a valid layer index, nothing
is removed.
- If
key
is a string
, removes the layer with
the name key
. Leading and trailing white space is removed,
matching is a case-insensitive sub-string match.
Parameters:
Name |
Type |
Description |
key |
number
|
string
|
indicates the layer to remove |
- Source:
-
Example
import josm from 'josm'
// remove the first layer
josm.layers.remove(0)
// remove the first layer matching with the supplied name
josm.layers.remove('myLayerName')