Skip to content

Commit

Permalink
Add maintenance functions including removeAll and coordinate output.
Browse files Browse the repository at this point in the history
Clean up a bunch of code and add comments.
  • Loading branch information
manthey committed Sep 2, 2016
1 parent 4e972f7 commit 130c89d
Show file tree
Hide file tree
Showing 5 changed files with 503 additions and 149 deletions.
2 changes: 1 addition & 1 deletion examples/annotations/example.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"exampleCss": ["main.css"],
"exampleJs": ["main.js"],
"about": {
"text": "This example shows how to add annotations, such as marked rectangles, to a map."
"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."
}
}
18 changes: 16 additions & 2 deletions examples/annotations/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@ var annotationDebug = {};
$(function () {
'use strict';

var layer;

function _mouseClickToStart(evt) {
if (evt.handled) {
return;
}
if (!layer.mode()) {
layer.mode(evt.buttonsDown.left ? 'polygon' : 'rectangle');
} else {
layer.mode(null);
}
}

var query = utils.getQuery();
var map = geo.map({
node: '#map',
Expand All @@ -23,10 +36,11 @@ $(function () {
annotationDebug.satelliteLayer = map.createLayer('osm', {url: 'http://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}.png', opacity: query.map === 'dual' ? 0.25 : 1});
}
}
var layer = map.createLayer('annotation', {
layer = map.createLayer('annotation', {
renderer: query.renderer ? (query.renderer === 'html' ? null : query.renderer) : undefined,
features: query.renderer ? undefined : ['polygon']
features: query.renderer ? undefined : ['polygon', 'line']
});
layer.geoOn(geo.event.mouseclick, _mouseClickToStart);

map.draw();

Expand Down
Binary file removed examples/annotations/thumb.jpg
Binary file not shown.
Loading

0 comments on commit 130c89d

Please sign in to comment.