(abstract) new Geometry() [source]
Extends:
Mixes From:
Fires:
- idchange
- propertieschange
- show
- hide
- zindexchange
- removestart
- removeend
- remove
- shapechange
- positionchange
- symbolchange
- dragstart
- dragging
- dragend
- mouseover
- mouseout
- add
Members
(constant) options
Properties:
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options
|
Object | geometry options
Properties
|
- Source:
Static Methods
(static) fromJSON(json) [source]
Produce a geometry from one or more JSON or GeoJSON.
var profile = {
"feature": {
"type": "Feature",
"id" : "point1",
"geometry": {"type": "Point", "coordinates": [102.0, 0.5]},
"properties": {"prop0": "value0"}
},
//construct options.
"options":{
"draggable" : true
},
//symbol
"symbol":{
"markerFile" : "http://foo.com/icon.png",
"markerWidth" : 20,
"markerHeight": 20
}
};
var marker = Geometry.fromJSON(profile);
Parameter | Type | Description |
---|---|---|
json
|
Object | a geometry's JSON or a geojson |
Returns:
Geometry: geometryMethods
getFirstCoordinate() [source]
Returns the first coordinate of the geometry.
Returns:
Coordinate: First CoordinategetLastCoordinate() [source]
Returns the last coordinate of the geometry.
Returns:
Coordinate: Last CoordinateaddTo(layer, fitviewopt) [source]
Adds the geometry to a layer
Parameter | Type | Default | Description |
---|---|---|---|
layer
|
Layer | layer add to | |
fitview
opt
|
Boolean | false | automatically set the map to a fit center and zoom for the geometry |
Fires:
Returns:
Geometry: thisgetLayer() [source]
Get the layer which this geometry added to.
Returns:
Layer: - layer added togetMap() [source]
Get the map which this geometry added to
Returns:
Map: - map added togetId() [source]
Gets geometry's id. Id is set by setId or constructor options.
Returns:
String|Number: geometry的idsetId(id) [source]
Set geometry's id.
Parameter | Type | Description |
---|---|---|
id
|
String | new id |
Fires:
Returns:
Geometry: thisgetProperties() [source]
Get geometry's properties. Defined by GeoJSON as feature's properties.
Returns:
Object: propertiessetProperties(properties) [source]
Set a new properties to geometry.
Parameter | Type | Description |
---|---|---|
properties
|
Object | new properties |
Fires:
Returns:
Geometry: thisgetType() [source]
Get type of the geometry, e.g. "Point", "LineString"
Returns:
String: type of the geometrygetSymbol() [source]
Get symbol of the geometry
Returns:
Object: geometry's symbolsetSymbol(symbol) [source]
Set a new symbol to style the geometry.
Parameter | Type | Description |
---|---|---|
symbol
|
Object | new symbol |
Fires:
Returns:
Geometry: thisupdateSymbol(props) [source]
Update geometry's current symbol.
var marker = new Marker([0, 0], {
symbol : {
markerType : 'ellipse',
markerWidth : 20,
markerHeight : 30
}
});
// update symbol's markerWidth to 40
marker.updateSymbol({
markerWidth : 40
});
Parameter | Type | Description |
---|---|---|
props
|
Object | symbol properties to update |
Fires:
Returns:
Geometry: thisgetCenter() [source]
Get the geographical center of the geometry.
Returns:
Coordinate:getExtent() [source]
Get the geometry's geographical extent
Returns:
Extent: geometry's extentgetSize() [source]
Get pixel size of the geometry, which may vary in different zoom levels.
Returns:
Size:containsPoint(point, topt) [source]
Whehter the geometry contains the input container point.
var circle = new Circle([0, 0], 1000)
.addTo(layer);
var contains = circle.containsPoint([400, 300]);
Parameter | Type | Description |
---|---|---|
point
|
Point | Coordinate | input container point or coordinate |
t
opt
|
Number | tolerance in pixel |
Returns:
Boolean:show() [source]
Show the geometry.
Fires:
Returns:
Geometry: thishide() [source]
Hide the geometry
Fires:
Returns:
Geometry: thisisVisible() [source]
Whether the geometry is visible
Returns:
Boolean:getZIndex() [source]
Get zIndex of the geometry, default is 0
Returns:
Number: zIndexsetZIndex(zIndex) [source]
Set a new zIndex to Geometry and fire zindexchange event (will cause layer to sort geometries and render)
Parameter | Type | Description |
---|---|---|
zIndex
|
Number | new zIndex |
Fires:
Returns:
Geometry: thissetZIndexSilently(zIndex) [source]
Only set a new zIndex to Geometry without firing zindexchange event.
Can be useful to improve perf when a lot of geometries' zIndex need to be updated.
When updated N geometries, You can use setZIndexSilently with (N-1) geometries and use setZIndex with the last geometry for layer to sort and render.
Can be useful to improve perf when a lot of geometries' zIndex need to be updated.
When updated N geometries, You can use setZIndexSilently with (N-1) geometries and use setZIndex with the last geometry for layer to sort and render.
Parameter | Type | Description |
---|---|---|
zIndex
|
Number | new zIndex |
Returns:
Geometry: thisbringToFront() [source]
Bring the geometry on the top
Fires:
Returns:
Geometry: thisbringToBack() [source]
Bring the geometry to the back
Fires:
Returns:
Geometry: thistranslate(offset) [source]
Translate or move the geometry by the given offset.
Parameter | Type | Description |
---|---|---|
offset
|
Coordinate | translate offset |
Fires:
Returns:
Geometry: thisflash(intervalopt, countopt, cbopt, contextopt) [source]
Flash the geometry, show and hide by certain internal for times of count.
Parameter | Type | Default | Description |
---|---|---|---|
interval
opt
|
Number | 100 | interval of flash, in millisecond (ms) |
count
opt
|
Number | 4 | flash times |
cb
opt
|
function | null | callback function when flash ended |
context
opt
|
* | null | callback context |
Returns:
Geometry: thiscopy() [source]
Returns a copy of the geometry without the event listeners.
Returns:
Geometry: copyremove() [source]
remove itself from the layer if any.
Fires:
Returns:
Geometry: thistoGeoJSONGeometry() [source]
Exports geometry out of a GeoJSON feature.
Returns:
Object: GeoJSON GeometrytoGeoJSON(optsopt) [source]
Exports a GeoJSON feature.
Parameter | Type | Default | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opts
opt
|
Object | null | export options
Properties
|
Returns:
Object: GeoJSON FeaturetoJSON(optionsopt) [source]
Export a profile json out of the geometry.
Besides exporting the feature object, a profile json also contains symbol, construct options and infowindow info.
The profile json can be stored somewhere else and be used to reproduce the geometry later.
Due to the problem of serialization for functions, event listeners and contextmenu are not included in profile json.
Besides exporting the feature object, a profile json also contains symbol, construct options and infowindow info.
The profile json can be stored somewhere else and be used to reproduce the geometry later.
Due to the problem of serialization for functions, event listeners and contextmenu are not included in profile json.
// an example of a profile json.
var profile = {
"feature": {
"type": "Feature",
"id" : "point1",
"geometry": {"type": "Point", "coordinates": [102.0, 0.5]},
"properties": {"prop0": "value0"}
},
//construct options.
"options":{
"draggable" : true
},
//symbol
"symbol":{
"markerFile" : "http://foo.com/icon.png",
"markerWidth" : 20,
"markerHeight": 20
},
//infowindow info
"infowindow" : {
"options" : {
"style" : "black"
},
"title" : "this is a infowindow title",
"content" : "this is a infowindow content"
}
};
Parameter | Type | Default | Description |
---|---|---|---|
options
opt
|
Object | null | export options |
opts.geometry
opt
|
Boolean | true | whether export feature's geometry |
opts.properties
opt
|
Boolean | true | whether export feature's properties |
opts.options
opt
|
Boolean | true | whether export construct options |
opts.symbol
opt
|
Boolean | true | whether export symbol |
opts.infoWindow
opt
|
Boolean | true | whether export infowindow |
Returns:
Object: profile json objectgetLength() [source]
Get the geographic length of the geometry.
Returns:
Number: geographic length, unit is metergetArea() [source]
Get the geographic area of the geometry.
Returns:
Number: geographic area, unit is sq.meterstartEdit(optionsopt) [source]
Start to edit
Parameter | Type | Default | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
options
opt
|
Object | null | edit options
Properties
|
Returns:
Geometry: thisendEdit() [source]
End editing.
Returns:
Geometry: thisisEditing() [source]
Whether the geometry is being edited.
Returns:
Boolean:isDragging() [source]
Whether the geometry is being dragged.
animate(styles, optionsopt, stepopt) [source]
Animate the geometry
var player = marker.animate({
'symbol': {
'markerHeight': 82
}
}, {
'speed': 2000
}, function (frame) {
console.log(frame);
});
player.pause();
Parameter | Type | Default | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
styles
|
Object | styles to animate | |||||||||||||||||
options
opt
|
Object | null | animation options
Properties
|
||||||||||||||||
step
opt
|
function | null | step function when animating |
Returns:
animation.Player: animation playersetInfoWindow(options) [source]
Set an InfoWindow to the geometry
geometry.setInfoWindow({
title : 'This is a title',
content : '<div style="color:#f00">This is content of the InfoWindow</div>'
});
Parameter | Type | Description |
---|---|---|
options
|
Object | construct options for the InfoWindow |
Returns:
Geometry: thisgetInfoWindow() [source]
Get the InfoWindow instance.
Returns:
ui.InfoWindow:openInfoWindow(coordinateopt) [source]
Open the InfoWindow, default on the center of the geometry.
Parameter | Type | Default | Description |
---|---|---|---|
coordinate
opt
|
Coordinate | null | coordinate to open the InfoWindow |
Returns:
Geometry: thiscloseInfoWindow() [source]
Close the InfoWindow
Returns:
Geometry: thisremoveInfoWindow() [source]
Remove the InfoWindow
Returns:
Geometry: this(mixin) on(eventsOn, handler, contextopt) [source]
Register a handler function to be called whenever this event is fired.
foo.on('mousedown mousemove mouseup', onMouseEvent, foo);
Parameter | Type | Default | Description |
---|---|---|---|
eventsOn
|
String | event types to register, seperated by space if more than one. | |
handler
|
function | handler function to be called | |
context
opt
|
Object | null | the context of the handler |
Mixes From:
Returns:
Any: this(mixin) addEventListener(eventTypes, handler, contextopt) [source]
Alias for on
Parameter | Type | Default | Description |
---|---|---|---|
eventTypes
|
String | event types to register, seperated by space if more than one. | |
handler
|
function | handler function to be called | |
context
opt
|
Object | null | the context of the handler |
Mixes From:
Returns:
: this(mixin) once(eventTypes, handler, contextopt) [source]
Same as on, except the listener will only get fired once and then removed.
foo.once('mousedown mousemove mouseup', onMouseEvent, foo);
Parameter | Type | Default | Description |
---|---|---|---|
eventTypes
|
String | event types to register, seperated by space if more than one. | |
handler
|
function | listener handler | |
context
opt
|
Object | null | the context of the handler |
Mixes From:
Returns:
: this(mixin) off(eventsOff, handler, contextopt) [source]
Unregister the event handler for the specified event types.
foo.off('mousedown mousemove mouseup', onMouseEvent, foo);
Parameter | Type | Default | Description |
---|---|---|---|
eventsOff
|
String | event types to unregister, seperated by space if more than one. | |
handler
|
function | listener handler | |
context
opt
|
Object | null | the context of the handler |
Mixes From:
Returns:
: this(mixin) removeEventListener(eventTypes, handler, contextopt) [source]
Alias for off
Parameter | Type | Default | Description |
---|---|---|---|
eventTypes
|
String | event types to unregister, seperated by space if more than one. | |
handler
|
function | listener handler | |
context
opt
|
Object | null | the context of the handler |
Mixes From:
Returns:
: this(mixin) listens(eventType, hanlderopt, contextopt) [source]
Returns listener's count registered for the event type.
Parameter | Type | Default | Description |
---|---|---|---|
eventType
|
String | an event type | |
hanlder
opt
|
function | null | listener function |
context
opt
|
Object | null | the context of the handler |
Mixes From:
Returns:
Number:(mixin) copyEventListeners(target) [source]
Copy all the event listener to the target object
Parameter | Type | Description |
---|---|---|
target
|
Object | target object to copy to. |
Mixes From:
Returns:
: this(mixin) fire(eventType, param) [source]
Fire an event, causing all handlers for that event name to run.
Parameter | Type | Description |
---|---|---|
eventType
|
String | an event type to fire |
param
|
Object | parameters for the listener function. |
Mixes From:
Returns:
: this(mixin) registerJSONType(type) [source]
It is a static method.
Register layer for JSON serialization and assign a JSON type.
Register layer for JSON serialization and assign a JSON type.
Parameter | Type | Description |
---|---|---|
type
|
String | JSON type |
Mixes From:
(mixin) getClass(type) [source]
It is a static method.
Get class of input JSON type
Get class of input JSON type
Parameter | Type | Description |
---|---|---|
type
|
String | JSON type |
Mixes From:
Returns:
Class: Class(mixin) getJSONType() [source]
Get object's JSON Type
Mixes From:
Returns:
String:(mixin) setMenu(options) [source]
Set a context menu
foo.setMenu({
'width' : 160,
'custom' : false,
'items' : [
//return false to prevent event propagation
{'item': 'Query', 'click': function() {alert('Query Clicked!'); return false;}},
'-',
{'item': 'Edit', 'click': function() {alert('Edit Clicked!')}},
{'item': 'About', 'click': function() {alert('About Clicked!')}}
]
});
Parameter | Type | Description |
---|---|---|
options
|
Object | menu options |
Mixes From:
Returns:
*: this(mixin) openMenu(coordinateopt) [source]
Open the context menu, default on the center of the geometry or map.
Parameter | Type | Default | Description |
---|---|---|---|
coordinate
opt
|
Coordinate | null | coordinate to open the context menu |
Mixes From:
Returns:
*: this(mixin) setMenuItems(items) [source]
Set menu items to the context menu
Parameter | Type | Description |
---|---|---|
items
|
Array.<Object> | menu items |
Mixes From:
Returns:
*: this(mixin) getMenuItems() [source]
Get the context menu items
Mixes From:
Returns:
Array.<Object>:(mixin) closeMenu() [source]
Close the contexnt menu
Mixes From:
Returns:
*: this(mixin) removeMenu() [source]
Remove the context menu
Mixes From:
Returns:
*: this(inherited) callInitHooks() [source]
Visit and call all the init hooks defined on Class and its parents.
Inherited From:
Returns:
Class: this(inherited) setOptions(options) [source]
Merges options with the default options of the object.
Parameter | Type | Description |
---|---|---|
options
|
Object | options to set |
Inherited From:
Returns:
Class: this(inherited) config(conf) [source]
1. Return object's options if no parameter is provided.
2. update an option and enable/disable the handler if a handler with the same name existed.
2. update an option and enable/disable the handler if a handler with the same name existed.
// Get marker's options;
var options = marker.config();
// Set map's option "draggable" to false and disable map's draggable handler.
map.config('draggable', false);
// You can update more than one options like this:
map.config({
'scrollWheelZoom' : false,
'doubleClickZoom' : false
});
Parameter | Type | Description |
---|---|---|
conf
|
Object | config to update |
Inherited From:
Returns:
Class: thisEvents
idchange [source]
idchange event.
Properties:
Name | Type | Description |
---|---|---|
type
|
String | idchange |
target
|
Geometry | the geometry fires the event |
old
|
String | Number | value of the old id |
new
|
String | Number | value of the new id |
- Source:
propertieschange [source]
propertieschange event, thrown when geometry's properties is changed.
Properties:
Name | Type | Description |
---|---|---|
type
|
String | propertieschange |
target
|
Geometry | the geometry fires the event |
old
|
String | Number | value of the old properties |
new
|
String | Number | value of the new properties |
- Source:
show [source]
show event
Properties:
Name | Type | Description |
---|---|---|
type
|
String | show |
target
|
Geometry | the geometry fires the event |
- Source:
hide [source]
hide event
Properties:
Name | Type | Description |
---|---|---|
type
|
String | hide |
target
|
Geometry | the geometry fires the event |
- Source:
zindexchange [source]
zindexchange event, fired when geometry's zIndex is changed.
Properties:
Name | Type | Description |
---|---|---|
type
|
String | zindexchange |
target
|
Geometry | the geometry fires the event |
old
|
Number | old zIndex |
new
|
Number | new zIndex |
- Source:
removestart [source]
removestart event.
Properties:
Name | Type | Description |
---|---|---|
type
|
String | removestart |
target
|
Geometry | the geometry fires the event |
- Source:
removeend [source]
removeend event.
Properties:
Name | Type | Description |
---|---|---|
type
|
String | removeend |
target
|
Geometry | the geometry fires the event |
- Source:
remove [source]
remove event.
Properties:
Name | Type | Description |
---|---|---|
type
|
String | remove |
target
|
Geometry | the geometry fires the event |
- Source:
shapechange [source]
shapechange event.
Properties:
Name | Type | Description |
---|---|---|
type
|
String | shapechange |
target
|
Geometry | the geometry fires the event |
- Source:
positionchange [source]
positionchange event.
Properties:
Name | Type | Description |
---|---|---|
type
|
String | positionchange |
target
|
Geometry | the geometry fires the event |
- Source:
symbolchange [source]
symbolchange event.
Properties:
Name | Type | Description |
---|---|---|
type
|
String | symbolchange |
target
|
Geometry | the geometry fires the event |
- Source:
dragstart [source]
drag start event
Properties:
Name | Type | Description |
---|---|---|
type
|
String | dragstart |
target
|
Geometry | the geometry fires event |
coordinate
|
Coordinate | coordinate of the event |
containerPoint
|
Point | container point of the event |
viewPoint
|
Point | view point of the event |
domEvent
|
Event | dom event |
- Source:
dragging [source]
dragging event
Properties:
Name | Type | Description |
---|---|---|
type
|
String | dragging |
target
|
Geometry | the geometry fires event |
coordinate
|
Coordinate | coordinate of the event |
containerPoint
|
Point | container point of the event |
viewPoint
|
Point | view point of the event |
domEvent
|
Event | dom event |
- Source:
dragend [source]
dragend event
Properties:
Name | Type | Description |
---|---|---|
type
|
String | dragend |
target
|
Geometry | the geometry fires event |
coordinate
|
Coordinate | coordinate of the event |
containerPoint
|
Point | container point of the event |
viewPoint
|
Point | view point of the event |
domEvent
|
Event | dom event |
- Source:
mouseover [source]
mouseover event for geometry
Properties:
Name | Type | Description |
---|---|---|
type
|
String | mouseover |
target
|
Geometry | the geometry fires mouseover |
coordinate
|
Coordinate | coordinate of the event |
containerPoint
|
Point | container point of the event |
viewPoint
|
Point | view point of the event |
domEvent
|
Event | dom event |
- Source:
mouseout [source]
mouseout event for geometry
Properties:
Name | Type | Description |
---|---|---|
type
|
String | mouseout |
target
|
Geometry | the geometry fires mouseout |
coordinate
|
Coordinate | coordinate of the event |
containerPoint
|
Point | container point of the event |
viewPoint
|
Point | view point of the event |
domEvent
|
Event | dom event |
- Source:
add [source]
add event.
Properties:
Name | Type | Description |
---|---|---|
type
|
String | add |
target
|
Geometry | geometry |
layer
|
Layer | the layer added to. |
- Source: