Skip to content

Commit

Permalink
Added convenience methods for setting basic marker options (issue #7)…
Browse files Browse the repository at this point in the history
…. Moved all of the documentation from the README to the wiki
  • Loading branch information
Scott Fairgrieve committed May 14, 2014
1 parent 0113ed5 commit efd56c8
Show file tree
Hide file tree
Showing 10 changed files with 180 additions and 773 deletions.
768 changes: 4 additions & 764 deletions README.md

Large diffs are not rendered by default.

48 changes: 48 additions & 0 deletions dist/leaflet-dvf.js
Original file line number Diff line number Diff line change
Expand Up @@ -2281,6 +2281,22 @@ L.MapMarker = L.Path.extend({
getLatLng: function() {
return this._latlng;
},
setRadius: function(radius) {
this.options.radius = radius;
return this.redraw();
},
setInnerRadius: function(innerRadius) {
this.options.innerRadius = innerRadius;
return this.redraw();
},
setRotation: function(rotation) {
this.options.rotation = rotation;
return this.redraw();
},
setNumberOfSides: function(numberOfSides) {
this.options.numberOfSides = numberOfSides;
return this.redraw();
},
getPathString: function() {
var anchorPoint = this.getTextAnchor();
if (this._shape) {
Expand Down Expand Up @@ -2382,6 +2398,34 @@ L.RegularPolygonMarker = L.Path.extend({
var map = this._map, radiusX = this.options.radius || this.options.radiusX, radiusY = this.options.radius || this.options.radiusY, deltaX = radiusX * Math.cos(Math.PI / 4), deltaY = radiusY * Math.sin(Math.PI / 4), point = map.project(this._latlng), swPoint = new L.Point(point.x - deltaX, point.y + deltaY), nePoint = new L.Point(point.x + deltaX, point.y - deltaY), sw = map.unproject(swPoint), ne = map.unproject(nePoint);
return new L.LatLngBounds(sw, ne);
},
setRadius: function(radius) {
this.options.radius = radius;
return this.redraw();
},
setRadiusXY: function(radiusX, radiusY) {
this.options.radius = null;
this.options.radiusX = radiusX;
this.options.radiusY = radiusY;
return this.redraw();
},
setInnerRadius: function(innerRadius) {
this.options.innerRadius = innerRadius;
return this.redraw();
},
setInnerRadiusXY: function(innerRadiusX, innerRadiusY) {
this.options.innerRadius = null;
this.options.innerRadiusX = innerRadiusX;
this.options.innerRadiusY = innerRadiusY;
return this.redraw();
},
setRotation: function(rotation) {
this.options.rotation = rotation;
return this.redraw();
},
setNumberOfSides: function(numberOfSides) {
this.options.numberOfSides = numberOfSides;
return this.redraw();
},
getLatLng: function() {
return this._latlng;
},
Expand Down Expand Up @@ -2452,6 +2496,10 @@ L.StarMarker = L.RegularPolygonMarker.extend({
gradient: true,
dropShadow: true
},
setNumberOfPoints: function(numberOfPoints) {
this.options.numberOfPoints = numberOfPoints;
return this.redraw();
},
_getPoints: function(inner) {
var maxDegrees = this.options.maxDegrees || 360;
var angleSize = maxDegrees / this.options.numberOfPoints;
Expand Down
48 changes: 48 additions & 0 deletions dist/leaflet-dvf.markers.js
Original file line number Diff line number Diff line change
Expand Up @@ -2219,6 +2219,22 @@ L.MapMarker = L.Path.extend({
getLatLng: function() {
return this._latlng;
},
setRadius: function(radius) {
this.options.radius = radius;
return this.redraw();
},
setInnerRadius: function(innerRadius) {
this.options.innerRadius = innerRadius;
return this.redraw();
},
setRotation: function(rotation) {
this.options.rotation = rotation;
return this.redraw();
},
setNumberOfSides: function(numberOfSides) {
this.options.numberOfSides = numberOfSides;
return this.redraw();
},
getPathString: function() {
var anchorPoint = this.getTextAnchor();
if (this._shape) {
Expand Down Expand Up @@ -2320,6 +2336,34 @@ L.RegularPolygonMarker = L.Path.extend({
var map = this._map, radiusX = this.options.radius || this.options.radiusX, radiusY = this.options.radius || this.options.radiusY, deltaX = radiusX * Math.cos(Math.PI / 4), deltaY = radiusY * Math.sin(Math.PI / 4), point = map.project(this._latlng), swPoint = new L.Point(point.x - deltaX, point.y + deltaY), nePoint = new L.Point(point.x + deltaX, point.y - deltaY), sw = map.unproject(swPoint), ne = map.unproject(nePoint);
return new L.LatLngBounds(sw, ne);
},
setRadius: function(radius) {
this.options.radius = radius;
return this.redraw();
},
setRadiusXY: function(radiusX, radiusY) {
this.options.radius = null;
this.options.radiusX = radiusX;
this.options.radiusY = radiusY;
return this.redraw();
},
setInnerRadius: function(innerRadius) {
this.options.innerRadius = innerRadius;
return this.redraw();
},
setInnerRadiusXY: function(innerRadiusX, innerRadiusY) {
this.options.innerRadius = null;
this.options.innerRadiusX = innerRadiusX;
this.options.innerRadiusY = innerRadiusY;
return this.redraw();
},
setRotation: function(rotation) {
this.options.rotation = rotation;
return this.redraw();
},
setNumberOfSides: function(numberOfSides) {
this.options.numberOfSides = numberOfSides;
return this.redraw();
},
getLatLng: function() {
return this._latlng;
},
Expand Down Expand Up @@ -2390,6 +2434,10 @@ L.StarMarker = L.RegularPolygonMarker.extend({
gradient: true,
dropShadow: true
},
setNumberOfPoints: function(numberOfPoints) {
this.options.numberOfPoints = numberOfPoints;
return this.redraw();
},
_getPoints: function(inner) {
var maxDegrees = this.options.maxDegrees || 360;
var angleSize = maxDegrees / this.options.numberOfPoints;
Expand Down
4 changes: 2 additions & 2 deletions dist/leaflet-dvf.markers.min.js

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions dist/leaflet-dvf.min.js

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion examples/html/sparklines.html
Original file line number Diff line number Diff line change
Expand Up @@ -1560,7 +1560,10 @@
fillColor: '#FF0000',
color: '#000000',
displayName: 'Category 1',
fillOpacity: 0.9
fillOpacity: 0.9,
displayText: function (value) {
return value;
}
}
},
layerOptions: {
Expand Down
6 changes: 4 additions & 2 deletions src/leaflet.dvf.datalayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -977,14 +977,16 @@ L.MarkerDataLayer = L.DataLayer.extend({
}
});

/*
*
*/
L.markerDataLayer = function (data, options) {
return new L.MarkerDataLayer(data, options);
};

/*
*
* Displays the top 50 photos for a given area on the map
*/

L.PanoramioLayer = L.MarkerDataLayer.extend({
statics: {
UPLOAD_DATE_FORMAT: 'DD MMM YYYY',
Expand Down
59 changes: 59 additions & 0 deletions src/leaflet.dvf.markers.js
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,26 @@ L.MapMarker = L.Path.extend({
return this._latlng;
},

setRadius: function (radius) {
this.options.radius = radius;
return this.redraw();
},

setInnerRadius: function (innerRadius) {
this.options.innerRadius = innerRadius;
return this.redraw();
},

setRotation: function (rotation) {
this.options.rotation = rotation;
return this.redraw();
},

setNumberOfSides: function (numberOfSides) {
this.options.numberOfSides = numberOfSides;
return this.redraw();
},

getPathString: function () {
var anchorPoint = this.getTextAnchor();

Expand Down Expand Up @@ -731,6 +751,40 @@ L.RegularPolygonMarker = L.Path.extend({
return new L.LatLngBounds(sw, ne);
},

setRadius: function (radius) {
this.options.radius = radius;
return this.redraw();
},

setRadiusXY: function (radiusX, radiusY) {
this.options.radius = null;
this.options.radiusX = radiusX;
this.options.radiusY = radiusY;
return this.redraw();
},

setInnerRadius: function (innerRadius) {
this.options.innerRadius = innerRadius;
return this.redraw();
},

setInnerRadiusXY: function (innerRadiusX, innerRadiusY) {
this.options.innerRadius = null;
this.options.innerRadiusX = innerRadiusX;
this.options.innerRadiusY = innerRadiusY;
return this.redraw();
},

setRotation: function (rotation) {
this.options.rotation = rotation;
return this.redraw();
},

setNumberOfSides: function (numberOfSides) {
this.options.numberOfSides = numberOfSides;
return this.redraw();
},

getLatLng: function () {
return this._latlng;
},
Expand Down Expand Up @@ -826,6 +880,11 @@ L.StarMarker = L.RegularPolygonMarker.extend({
dropShadow: true
},

setNumberOfPoints: function (numberOfPoints) {
this.options.numberOfPoints = numberOfPoints;
return this.redraw();
},

_getPoints: function (inner) {
var maxDegrees = this.options.maxDegrees || 360;
var angleSize = maxDegrees / this.options.numberOfPoints;
Expand Down
5 changes: 4 additions & 1 deletion src/leaflet.dvf.palettes.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ L.Palettes = {
};

/*
* Pre-defined color palettes for easy use
* Pre-defined color palettes for easy use. Call getPalette passing a min and max value get a pre-defined LinearFunction
*/
L.DynamicColorPalettes = {
rainbow: {
Expand Down Expand Up @@ -500,6 +500,9 @@ L.DynamicColorPalettes = {
}
};

/*
*
*/
L.DynamicPaletteElement = L.Class.extend({
initialize: function (key, dynamicPalette) {
this._key = key;
Expand Down
3 changes: 3 additions & 0 deletions src/leaflet.dvf.utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,9 @@ L.Color = L.Class.extend({
}
});

/*
* A class representing an RGB color - extends L.Color
*/
L.RGBColor = L.Color.extend({
initialize: function (colorDef) {
L.Color.prototype.initialize.call(this, colorDef);
Expand Down

0 comments on commit efd56c8

Please sign in to comment.