Skip to content

Commit c3c4eaf

Browse files
authored
Merge pull request #681 from OpenGeoscience/lines-annotation
Added line annotations.
2 parents 663a5c4 + 8104c71 commit c3c4eaf

File tree

11 files changed

+871
-33
lines changed

11 files changed

+871
-33
lines changed

examples/annotations/example.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
"exampleCss": ["main.css"],
55
"exampleJs": ["main.js"],
66
"about": {
7-
"text": "This example shows how to add annotations, such as marked rectangles, to a map. Left click to add a polygon, right click to add a rectangle."
7+
"text": "This example shows how to add annotations, such as marked rectangles, to a map."
88
}
99
}

examples/annotations/index.jade

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ block append mainContent
66
.shortlabel Add
77
button#rectangle.lastused(next='polygon') Rectangle
88
button#polygon(next='point') Polygon
9-
button#point(next='rectangle') Point
9+
button#point(next='line') Point
10+
button#line(next='rectangle') Line
1011
.form-group
1112
#instructions(annotation='none')
1213
.annotation.none
1314
.annotation.polygon Left-click points in the polygon. Double click, right click, or click the starting point to close the polygon.
14-
.annotation.rectangle Left click-and-drag to draw a rectangle.
15+
.annotation.rectangle Left click-and-drag or left click opposite corners to draw a rectangle.
1516
.annotation.point Left click to create a point.
17+
.annotation.line Left-click points in the line. Double click, right click, or click the starting point to end the line.
1618
.form-group(title='If enabled, left-click to add another annotation, and right-click to switch annotation type. Otherwise, you must click a button above.')
1719
label(for='clickadd') Click to add annotation
1820
input#clickadd(param-name='clickadd', type='checkbox', placeholder='true', checked='checked')
@@ -64,15 +66,33 @@ block append mainContent
6466
select#edit-stroke(option='stroke', format='boolean')
6567
option(value='true') Yes
6668
option(value='false') No
67-
.form-group(annotation-types='point polygon rectangle')
69+
.form-group(annotation-types='point polygon rectangle line')
6870
label(for='edit-strokeWidth') Stroke Width
6971
input#edit-strokeWidth(option='strokeWidth', format='positive')
70-
.form-group(annotation-types='point polygon rectangle')
72+
.form-group(annotation-types='point polygon rectangle line')
7173
label(for='edit-strokeColor') Stroke Color
7274
input#edit-strokeColor(option='strokeColor', format='color')
73-
.form-group(annotation-types='point polygon rectangle')
75+
.form-group(annotation-types='point polygon rectangle line')
7476
label(for='edit-strokeOpacity') Stroke Opacity
7577
input#edit-strokeOpacity(option='strokeOpacity', format='opacity')
78+
.form-group(annotation-types='line')
79+
label(for='edit-closed') Closed
80+
select#edit-closed(option='closed', format='boolean')
81+
option(value='true') Yes
82+
option(value='false') No
83+
.form-group(annotation-types='line')
84+
label(for='edit-lineCap') Line End Caps
85+
select#edit-lineCap(option='lineCap', format='text')
86+
option(value='butt') Butt
87+
option(value='round') Round
88+
option(value='square') Square
89+
.form-group(annotation-types='line')
90+
label(for='edit-lineJoin') Line Joins
91+
select#edit-lineJoin(option='lineJoin', format='text')
92+
option(value='miter') Miter
93+
option(value='bevel') Bevel
94+
option(value='round') Round
95+
option(value='miter-clip') Miter-Clip
7696
.form-group
7797
#edit-validation-error
7898
.modal-footer

examples/annotations/main.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
#instructions[annotation="polygon"] .annotation.polygon,
5555
#instructions[annotation="rectangle"] .annotation.rectangle,
5656
#instructions[annotation="point"] .annotation.point,
57+
#instructions[annotation="line"] .annotation.line,
5758
#instructions[annotation="none"] .annotation.none {
5859
display: block;
5960
}

examples/lines/main.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,10 @@ $(function () {
347347
.position(function (d) {
348348
return {x: d[0], y: d[1]};
349349
})
350-
// add hover events
351-
.geoOn(geo.event.feature.mouseover, function (evt) {
350+
// add hover events -- use mouseon and mouseoff, since we only show one
351+
// tootip. If we showed one tooltip per item we were over, use mouseover
352+
// and mouseout.
353+
.geoOn(geo.event.feature.mouseon, function (evt) {
352354
var text = (evt.data.name ? evt.data.name : '') +
353355
(evt.data.highway ? ' (' + evt.data.highway + ')' : '');
354356
if (text) {
@@ -357,7 +359,7 @@ $(function () {
357359
}
358360
tooltipElem.toggleClass('hidden', !text);
359361
})
360-
.geoOn(geo.event.feature.mouseout, function (evt) {
362+
.geoOn(geo.event.feature.mouseoff, function (evt) {
361363
tooltipElem.addClass('hidden');
362364
});
363365

src/action.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ var geo_action = {
1515
zoomselect: 'geo_action_zoomselect',
1616

1717
// annotation actions
18+
annotation_line: 'geo_annotation_line',
1819
annotation_polygon: 'geo_annotation_polygon',
1920
annotation_rectangle: 'geo_annotation_rectangle'
2021
};

0 commit comments

Comments
 (0)