|
|
|
### _onCreated in DrawTools.js
|
|
|
|
# _onCreated in DrawTools.js
|
|
|
|
Only one element at a time goes to the _onCreated-function.
|
|
|
|
#### General
|
|
|
|
## General
|
|
|
|
_leaflet_id is unique for every element.
|
|
|
|
|
|
|
|
The map's dragging can be controlled with dragging.enable() and dragging.disable() functions, i.e. e.layer._map.dragging.disable()
|
| ... | ... | @@ -16,7 +16,7 @@ e |
|
|
|
| └── stroke
|
|
|
|
└── layerType
|
|
|
|
```
|
|
|
|
#### Marker, TextBox
|
|
|
|
## Marker, TextBox
|
|
|
|
Information from _tooltip is mostly relevant only to Textboxes.
|
|
|
|
```
|
|
|
|
e
|
| ... | ... | @@ -31,14 +31,14 @@ e |
|
|
|
├── opacity
|
|
|
|
└── permanent
|
|
|
|
```
|
|
|
|
#### Polyline, Polygon
|
|
|
|
## Polyline, Polygon
|
|
|
|
In Polylines and Polygons, the coordinates are located in the _latlngs variable, not _latlng.
|
|
|
|
```
|
|
|
|
e
|
|
|
|
└── layer
|
|
|
|
└── _latlngs
|
|
|
|
```
|
|
|
|
#### Circle
|
|
|
|
## Circle
|
|
|
|
Circles have only one set of coordinates under _latlng variable, similar to markers and textboxes. The size is determined with radius.
|
|
|
|
|
|
|
|
The radius variable under e.layer.options does not update. _mRadius has the true radius value.
|
| ... | ... | @@ -48,7 +48,7 @@ e |
|
|
|
├── _latlng
|
|
|
|
└── _mRadius
|
|
|
|
```
|
|
|
|
#### Rectangle
|
|
|
|
## Rectangle
|
|
|
|
Similarly to Polyline and Polygon, rectangle also has _latlngs variable which always is an array of four, but only the coordinates of the opposite corners are really needed to get the rectangle's size.
|
|
|
|
```
|
|
|
|
e
|
| ... | ... | @@ -59,7 +59,7 @@ e |
|
|
|
└── _latlngs
|
|
|
|
```
|
|
|
|
|
|
|
|
### _onEdited and _onDeleted in DrawTools.js
|
|
|
|
# _onEdited and _onDeleted in DrawTools.js
|
|
|
|
_onEdited and _onDeleted functions are fired when the user edits or deletes elements and clicks Save. Thus the object that is given to these functions is a list of elements with some additional information. The essential part of this object is that each drawn element is listed under their leaflet ids, not just a basic array. It's necessary to use eachLayer function, if one wants to do something with single elements.
|
|
|
|
```
|
|
|
|
e
|
| ... | ... | @@ -69,7 +69,7 @@ e |
|
|
|
```
|
|
|
|
The contents of each leaflet ID is the same as in _onCreated function, depending on the element's type.
|
|
|
|
|
|
|
|
### JSON objects to which elements are saved in database
|
|
|
|
# Drawings' JSON format
|
|
|
|
We used to use the GeoJSON standard included with Leaflet to save each element into, but it proved highly inconvenient to parse the elements out to draw on the map again. Thus we made our own JSON format.
|
|
|
|
```
|
|
|
|
data
|
| ... | ... | @@ -90,3 +90,53 @@ Marker, TextBox and Circle coordinates are saved as a single set of coordinates. |
|
|
|
Type determines what type of a drawing it is. If it's a circle or a textbox, there's an extra field for radius and text, respectively.
|
|
|
|
|
|
|
|
drawingIsActive is a boolean value for whether the drawing is deleted or not; drawings will never be removed from the database completely, as they are still needed for replays. faction has information related to the faction that drew the drawing, and mapDrawingId is, well, the id of the drawing which is generated in the back-end.
|
|
|
|
|
|
|
|
# Players' JSON format
|
|
|
|
Players are contained under multiple arrays.
|
|
|
|
|
|
|
|
```
|
|
|
|
{{faction 1}}
|
|
|
|
├── {{group 1}}
|
|
|
|
| ├── {{player 1}}
|
|
|
|
| | ├── coordinates
|
|
|
|
| | | ├── lat
|
|
|
|
| | | ├── lng
|
|
|
|
| | | └── time
|
|
|
|
| | ├── factionColour
|
|
|
|
| | ├── factionId
|
|
|
|
| | ├── gamepersonId
|
|
|
|
| | ├── gamepersonRole
|
|
|
|
| | ├── icon
|
|
|
|
| | └── username
|
|
|
|
| ├── {{player 2}}
|
|
|
|
...
|
|
|
|
├── {{group 2}}
|
|
|
|
...
|
|
|
|
{{faction 2}}
|
|
|
|
...
|
|
|
|
```
|
|
|
|
Coordinates include time for replay purposes. Icons are in .svg format.
|
|
|
|
|
|
|
|
# Flagbox's JSON format
|
|
|
|
|
|
|
|
```
|
|
|
|
action
|
|
|
|
├── message
|
|
|
|
└── status
|
|
|
|
capture
|
|
|
|
├── colour
|
|
|
|
└── factionName
|
|
|
|
data
|
|
|
|
├── coordinates
|
|
|
|
| ├── {{lat}}
|
|
|
|
| └── {{lng}}
|
|
|
|
├── type
|
|
|
|
objectivePointDescription
|
|
|
|
objectivePointId
|
|
|
|
objectivePointMultiplier
|
|
|
|
owner
|
|
|
|
├── colour
|
|
|
|
└── factionName
|
|
|
|
```
|
|
|
|
|
|
|
|
... |
|
|
\ No newline at end of file |