Class: Editor

.xyz.maps.editor. Editor

A map editor is a class which enables the user to add, modify, delete and work with different kind of map objects. Changes can be committed to the backend database or only stay local.

new Editor(display, config)

Create an instance of the editor which is the main class within maphub maps API, you have to interact with.
A map editor is a class which enables the user to add, modify, delete and work with different kind of map
objects. Changes can be committed to the backend database or only stay locally.
Parameters:
Name Type Description
display Object The map display which could be instance of Here map or Tiger map.
config here.xyz.maps.editor.Editor.Config The config object containing customized settings.
Example:
//create Map display
 var display = new here.xyz.maps.Map( mapDiv, {
     zoomLevel : 19,
     center: {
         latitude: 50.10905256955773, longitude: 8.657339975607162
     },
     // add layers to display
     layers: layers
 });

 // create the editor instance
 editor = new MapEditor( display, config);

 

Classes

Config
drawingBoard
zoneSelector

Namespaces

drawingBoard

Members Summary

container :Node

The DIV container for the Map Editor.

Methods Summary

active(on) → {boolean}

enable or disable the editor.

addEventListener(event, callback, context)

This method registers an event listener.

addFeature(feature, layer, origin) → {here.xyz.maps.editor.features.Feature|here.xyz.maps.editor.features.Container}

Add defined features to map.

addFeature(layermap, origin) → {here.xyz.maps.editor.features.Feature|here.xyz.maps.editor.features.Container}

Add defined features to map.

addLayer(layer) → {boolean}

add the layer to enable editing.

addObserver(key, observer)

This method registers an observer for the property named by the caller.

clearObjectSelection() → {here.xyz.maps.editor.features.Feature|null}

Clears current selected object.

createFeatureContainer() → {here.xyz.maps.editor.features.Container}

Create an empty object container.

destroy()

Destroys this editor.

export() → {String}

Export information of all modified Objects. A Json string of modified Objects will be return by this function.

geoToPixel(p) → {here.xyz.maps.editor.PixelCoordinate}

Convert geo coordinate to pixel coordinate.

get(key) → {variant}

This method retrieves the current value of a observable property.

getDrawingBoard() → {here.xyz.maps.editor.Editor.drawingBoard}

get manager for drawing links or areas by mouse clicks.

getFeature(objId, layerId) → {here.xyz.maps.editor.features.Feature|null}

Get a feature.

getLayers() → {Array.<here.xyz.maps.layers.TileLayer>}

Get all layers that are added to the editor.

getOverlay() → {here.xyz.maps.layers.TileLayer}

Returns overlay layer for user interaction.

getZoneSelector() → {here.xyz.maps.editor.Editor.zoneSelector}

get tool for selecting zones/sides at links.

getZoomLevel() → {number}

Get the current zoomLevel.

import(json)

Import information of Objects. A Json string of Objects is imported to the editor.

info() → {Array}

Get information of all modified Objects.
an array of modified objects will be return by this function.

pixelToGeo(p) → {here.xyz.maps.editor.GeoCoordinate}

Convert pixel coordinate to geo coordinate.

redo(steps)

Redo the latest change(s).
One change entry can contain multiple object modifications.
The changes are stores in the local storage.
A here.xyz.maps.editor.Editor#submit request clears the local storage.

removeEventListener(event, callback)

Removes an event listener.

removeLayer(layer) → {boolean}

Remove a layer from the editor.

removeObserver(key, observer)

This method removes the observer for the property.

revert()

Revert changes, fetch data from repository.

search(options) → {Array.<here.xyz.maps.editor.features.Feature>}

Search for editable object(s).

setZoomLevel(zoomLevel)

Sets the desired zoomLevel.

submit(options) → {Boolean}

Submit changes, return object Ids of submitted objects. Reload and render objects.

undo(steps)

Undo the latest change(s).
One change entry can contain multiple object modifications.
The changes are stores in the local storage.
A here.xyz.maps.editor.Editor#submit request clears the local storage.

Members Details

container :Node

The DIV container for the Map Editor.
Type:
Node

Methods Details

active(on) → {boolean}

enable or disable the editor.
Parameters:
Name Type Description
on Boolean boolean value to enable or disable the editor
Returns:
current active state
Type:
boolean

addEventListener(event, callback, context)

This method registers an event listener.
Parameters:
Name Type Argument Description
event string Possible events are: 'tap', 'dbltap', 'pointerup', 'pointerenter', 'pointerleave', 'featureUnselected', 'error', 'dragStart', 'dragStop'
callback function The callback will be called when the specific event has been triggered. These are the explanations on the different events: - "tap", "pointerup", "dbltap": These events are thrown when the user taps (or double taps) on any feature of the map. -"pointerenter", "pointerleave": Triggered when mouse is over / moves out of an object. -"featureUnselected": This event is thrown when an feature is unselected, the unselect is done by Editor ( ex: automatic linksplit ). -"error": The event is thrown when error occurs. -"dragStop": The event is triggered when Address, POI, shape point of a link stops being dragged -"dragStart": The event is triggered when Address, POI or shape point of a link starts to be dragged.
context Object <optional>
The object to which "this" should refer to if the callback method is called.

addFeature(feature, layer, origin) → {here.xyz.maps.editor.features.Feature|here.xyz.maps.editor.features.Container}

Add defined features to map.
Parameters:
Name Type Argument Description
feature here.xyz.maps.editor.features.Feature | Array.<here.xyz.maps.editor.features.Feature> the feature(s) to be added to map.
layer here.xyz.maps.layers.TileLayer <optional>
layer the feature(s) should be added.
origin here.xyz.maps.editor.GeoCoordinate <optional>
allows to translate features by origin offset.
Returns:
feature(s) that were successfully added to map
Type:
here.xyz.maps.editor.features.Feature | here.xyz.maps.editor.features.Container

addFeature(layermap, origin) → {here.xyz.maps.editor.features.Feature|here.xyz.maps.editor.features.Container}

Add defined features to map.
Parameters:
Name Type Argument Description
layermap Object.<(string|number), (here.xyz.maps.editor.features.Feature|Array.<here.xyz.maps.editor.features.Feature>)> layermap is an object with layerId, feature ([feature]) pairs.
origin here.xyz.maps.editor.GeoCoordinate <optional>
allows to translate features by origin offset.
Returns:
feature(s) that were successfully added to map
Type:
here.xyz.maps.editor.features.Feature | here.xyz.maps.editor.features.Container

addLayer(layer) → {boolean}

add the layer to enable editing.
Parameters:
Name Type Description
layer here.xyz.maps.layers.TileLayer the layer to be added to map.
Returns:
true indicates layer is added successfully, otherwise false.
Type:
boolean

addObserver(key, observer)

This method registers an observer for the property named by the caller.
Parameters:
Name Type Description
key string The name of the property to observe. supported: 'active', 'ready', 'history.current', 'history.length', 'changes.length'
observer function The function to be called if the observed property is modified; the function must be able to receive the following arguments: {string} key - the name of the property that was modified, created or deleted {variant} value - the new value that the property should be set to {variant} oldValue the old value of the property

clearObjectSelection() → {here.xyz.maps.editor.features.Feature|null}

Clears current selected object.
Returns:
cleared object or null if none was selected.
Type:
here.xyz.maps.editor.features.Feature | null

createFeatureContainer() → {here.xyz.maps.editor.features.Container}

Create an empty object container.
Returns:
object container
Type:
here.xyz.maps.editor.features.Container

destroy()

Destroys this editor.

export() → {String}

Export information of all modified Objects. A Json string of modified Objects will be return by this function.
Returns:
Json String of modified Objects.
Type:
String

geoToPixel(p) → {here.xyz.maps.editor.PixelCoordinate}

Convert geo coordinate to pixel coordinate.
Parameters:
Name Type Description
p here.xyz.maps.editor.GeoCoordinate WGS84 Coordinate, object with properties latitude(as degree) and longitude(as degree)
Returns:
The pixel coordinate.
Type:
here.xyz.maps.editor.PixelCoordinate

get(key) → {variant}

This method retrieves the current value of a observable property.
Parameters:
Name Type Description
key string The name of the property whose value is to be retrieved
Returns:
value The retrieved value of the property or undefined if no such property exists
Type:
variant

getDrawingBoard() → {here.xyz.maps.editor.Editor.drawingBoard}

get manager for drawing links or areas by mouse clicks.
Returns:
Type:
here.xyz.maps.editor.Editor.drawingBoard

getFeature(objId, layerId) → {here.xyz.maps.editor.features.Feature|null}

Get a feature.
Parameters:
Name Type Description
objId String | Number id of the object
layerId String layerId of layer to which the object belongs
Returns:
return the found object in map. If the object is not found in current viewport, null is returned.
Type:
here.xyz.maps.editor.features.Feature | null

getLayers() → {Array.<here.xyz.maps.layers.TileLayer>}

Get all layers that are added to the editor.
Returns:
all layers that are added to map in array
Type:
Array.<here.xyz.maps.layers.TileLayer>

getOverlay() → {here.xyz.maps.layers.TileLayer}

Returns overlay layer for user interaction.
Returns:
Type:
here.xyz.maps.layers.TileLayer

getZoneSelector() → {here.xyz.maps.editor.Editor.zoneSelector}

get tool for selecting zones/sides at links.
Returns:
Type:
here.xyz.maps.editor.Editor.zoneSelector

getZoomLevel() → {number}

Get the current zoomLevel.
Returns:
The current zoomLevel.
Type:
number

import(json)

Import information of Objects. A Json string of Objects is imported to the editor.
Parameters:
Name Type Description
json String Json string of featuress.

info() → {Array}

Get information of all modified Objects.
an array of modified objects will be return by this function.
Returns:
Array of modified objects.
Type:
Array

pixelToGeo(p) → {here.xyz.maps.editor.GeoCoordinate}

Convert pixel coordinate to geo coordinate.
Parameters:
Name Type Description
p here.xyz.maps.editor.PixelCoordinate The pixel coordinate.
Returns:
WGS84 Coordinate, object with properties latitude(as degree) and longitude(as degree)
Type:
here.xyz.maps.editor.GeoCoordinate

redo(steps)

Redo the latest change(s).
One change entry can contain multiple object modifications.
The changes are stores in the local storage.
A here.xyz.maps.editor.Editor#submit request clears the local storage.
Parameters:
Name Type Argument Description
steps number <optional>
the number of change entries to redo, optional.

removeEventListener(event, callback)

Removes an event listener.
Parameters:
Name Type Description
event string Possible events are: 'pointerup', 'dblclick', 'pointerenter', 'pointerleave' 'featureUnselected', 'error', 'dragStart', 'dragStop'
callback function The callback function which will be removed.

removeLayer(layer) → {boolean}

Remove a layer from the editor.
Parameters:
Name Type Description
layer here.xyz.maps.layers.TileLayer the layer to be removed from map.
Returns:
true indicates layer is removed successfully, otherwise false.
Type:
boolean

removeObserver(key, observer)

This method removes the observer for the property.
Parameters:
Name Type Description
key string The name of the property that should no longer be observed
observer function The observer method to be removed

revert()

Revert changes, fetch data from repository.
Search for editable object(s).
Parameters:
Name Type Description
options Object
Properties
Name Type Argument Description
id String <optional>
Object id.
ids Array.<String> <optional>
Array of object ids.
point here.xyz.maps.geo.Point <optional>
Center point of the circle for search
radius number <optional>
Search radius in meters, if "point" search is performed.
rect here.xyz.maps.geo.Rect | Array.<number> <optional>
Rect object is either an array: [minLon, minLat, maxLon, maxLat] or Rect object defining rectangle to search in.
remote Boolean <optional>
Force the provider to do remote search if objects are not found in cache.
onload function <optional>
Callback function of search if remote search is performed.
filter function <optional>
function for optional result filtering.
layers Array.<here.xyz.maps.layers.TileLayer> <optional>
Layers to search in.
Returns:
array of features
Type:
Array.<here.xyz.maps.editor.features.Feature>
Examples:
//searching by id:
editor.search({id: 1058507462})
//or:
editor.search({ids: [1058507462, 1058507464]})
//searching by point and radius:
editor.search({
 point: {longitude: 72.84205, latitude: 18.97172},
 radius: 100
})
//searching by Rect:
editor.search({
 rect:  {minLon: 72.83584, maxLat: 18.97299, maxLon: 72.84443, minLat: 18.96876}
})
//remote search:
editor.search({
 rect:  {minLon: 72.83584, maxLat: 18.97299, maxLon: 72.84443, minLat: 18.96876},
 remote: true, // force provider to do remote search if feature/search area is not cached locally
 onload: function(e){
  // search result is only return in this callback function if no feature is not found in cache.
 }
})
 

setZoomLevel(zoomLevel)

Sets the desired zoomLevel.
Parameters:
Name Type Description
zoomLevel number The zoomLevel which should be set.

submit(options) → {Boolean}

Submit changes, return object Ids of submitted objects. Reload and render objects.
Parameters:
Name Type Argument Description
options Object <optional>
Properties
Name Type Argument Default Description
onSuccess function <optional>
callback function which returns additional information about the commit process.
onError function <optional>
callback function in error case.
transactionId string <optional>
transactionId of submit bundle.
ignoreEventBlock boolean <optional>
false In some special cases when events are blocked(sync is triggered), set this to true to force commiting objects.
Returns:
true, if there are changes to be submitted, false otherwise.
Type:
Boolean

undo(steps)

Undo the latest change(s).
One change entry can contain multiple object modifications.
The changes are stores in the local storage.
A here.xyz.maps.editor.Editor#submit request clears the local storage.
Parameters:
Name Type Argument Description
steps number <optional>
the number of change entries to undo, optional.