Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test layer.js. #949

Merged
merged 1 commit into from
Nov 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
- Removed the dependency on the vgl module for the `object` and `timestamp` classes (#918)
- CSS color names are obtained from an npm package rather than being defined in the util module (#936)

### Bug Fixes
- Fixed some minor issues with layers (#949)

## Version 0.18.1

### Bug Fixes
Expand Down
60 changes: 33 additions & 27 deletions src/annotationLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,34 @@ var $ = require('jquery');
var Mousetrap = require('mousetrap');
var textFeature = require('./textFeature');

/**
* Object specification for an annotation layer.
*
* @typedef {geo.layer.spec} geo.annotationLayer.spec
* @extends {geo.layer.spec}
* @property {number} [dblClickTime=300] The delay in milliseconds that is
* treated as a double-click when working with annotations.
* @property {number} [adjacentPointProximity=5] The minimum distance in
* display coordinates (pixels) between two adjacent points when creating a
* polygon or line. A value of 0 requires an exact match.
* @property {number} [continuousPointProximity=5] The minimum distance in
* display coordinates (pixels) between two adjacent points when dragging
* to create an annotation. `false` disables continuous drawing mode.
* @property {number} [continuousPointColinearity=1.0deg] The minimum angle
* between a series of three points when dragging to not interpret them as
* colinear. Only applies if `continuousPointProximity` is not `false`.
* @property {number} [finalPointProximity=10] The maximum distance in display
* coordinates (pixels) between the starting point and the mouse coordinates
* to signal closing a polygon. A value of 0 requires an exact match. A
* negative value disables closing a polygon by clicking on the start point.
* @property {boolean} [showLabels=true] Truthy to show feature labels that are
* allowed by the associated feature to be shown.
* @property {boolean} [clickToEdit=false] Truthy to allow clicking an
* annotation to place it in edit mode.
* @property {geo.textFeature.styleSpec} [defaultLabelStyle] Default styles for
* labels.
*/

/**
* @typedef {object} geo.annotationLayer.labelRecord
* @property {string} text The text of the label
Expand All @@ -26,41 +54,19 @@ var textFeature = require('./textFeature');
* @class
* @alias geo.annotationLayer
* @extends geo.featureLayer
* @param {object} [args] Layer options.
* @param {number} [args.dblClickTime=300] The delay in milliseconds that is
* treated as a double-click when working with annotations.
* @param {number} [args.adjacentPointProximity=5] The minimum distance in
* display coordinates (pixels) between two adjacent points when creating a
* polygon or line. A value of 0 requires an exact match.
* @param {number} [args.continuousPointProximity=5] The minimum distance in
* display coordinates (pixels) between two adjacent points when dragging
* to create an annotation. `false` disables continuous drawing mode.
* @param {number} [args.continuousPointColinearity=1.0deg] The minimum
* angle between a series of three points when dragging to not interpret
* them as colinear. Only applies if `continuousPointProximity` is not
* `false`.
* @param {number} [args.finalPointProximity=10] The maximum distance in
* display coordinates (pixels) between the starting point and the mouse
* coordinates to signal closing a polygon. A value of 0 requires an exact
* match. A negative value disables closing a polygon by clicking on the
* start point.
* @param {boolean} [args.showLabels=true] Truthy to show feature labels that
* are allowed by the associated feature to be shown.
* @param {boolean} [args.clickToEdit=false] Truthy to allow clicking an
* annotation to place it in edit mode.
* @param {object} [args.defaultLabelStyle] Default styles for labels.
* @param {geo.annotationLayer.spec} [arg] Specification for the new layer.
* @returns {geo.annotationLayer}
* @fires geo.event.annotation.state
* @fires geo.event.annotation.coordinates
* @fires geo.event.annotation.edit_action
* @fires geo.event.annotation.select_edit_handle
*/
var annotationLayer = function (args) {
var annotationLayer = function (arg) {
'use strict';
if (!(this instanceof annotationLayer)) {
return new annotationLayer(args);
return new annotationLayer(arg);
}
featureLayer.call(this, args);
featureLayer.call(this, arg);

var mapInteractor = require('./mapInteractor');
var timestamp = require('./timestamp');
Expand Down Expand Up @@ -130,7 +136,7 @@ var annotationLayer = function (args) {
finalPointProximity: 10, // in pixels, 0 is exact
showLabels: true,
clickToEdit: false
}, args);
}, arg);

/**
* Process an action event. If we are in rectangle-creation mode, this
Expand Down
4 changes: 2 additions & 2 deletions src/canvas/canvasRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ var canvasRenderer = function (arg) {

s_init.call(m_this);

var canvas = $(document.createElement('canvas'));
var canvas = arg.canvas || $(document.createElement('canvas'));
m_this.context2d = canvas[0].getContext('2d');

canvas.addClass('canvas-canvas');
Expand Down Expand Up @@ -113,7 +113,7 @@ var canvasRenderer = function (arg) {
var layer = m_this.layer(),
map = layer.map(),
mapSize = map.size(),
features = layer.features(),
features = layer.features ? layer.features() : [],
i;

for (i = 0; i < features.length; i += 1) {
Expand Down
2 changes: 1 addition & 1 deletion src/d3/d3Renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ var d3Renderer = function (arg) {
.attr('mode', 'normal');

if (!arg.widget) {
canvas = m_svg.append('g');
canvas = arg.canvas || m_svg.append('g');
zachmullen marked this conversation as resolved.
Show resolved Hide resolved
}

shadow = m_defs.append('filter')
Expand Down
2 changes: 1 addition & 1 deletion src/featureLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var registry = require('./registry');
* @class
* @alias geo.featureLayer
* @extends geo.layer
* @param {object} arg Options for the new layer.
* @param {geo.layer.spec} [arg] Specification for the new layer.
* @returns {geo.featureLayer}
*/
var featureLayer = function (arg) {
Expand Down
2 changes: 1 addition & 1 deletion src/gl/vglRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ var vglRenderer = function (arg) {

s_init.call(m_this);

var canvas = $(document.createElement('canvas'));
var canvas = arg.canvas || $(document.createElement('canvas'));
canvas.addClass('webgl-canvas');
$(m_this.layer().node().get(0)).append(canvas);

Expand Down
Loading