Skip to content

Commit

Permalink
Merge pull request #8 from jonoyuan/gh-pages
Browse files Browse the repository at this point in the history
Change the triangles to equilateral triangle based on a circle with given radius. Change size of diamonds to match area of square.
  • Loading branch information
rowanwins authored Dec 20, 2019
2 parents 04e89d0 + d81a14c commit 9013820
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions dist/leaflet-svg-shape-markers.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ L.SVG.include({
var shape = layer.options.shape;

if(shape === "diamond"){
var d = "M"+ (p.x-s)+ " "+ (p.y)+ " L " + (p.x) +" "+ (p.y-s)+ " L" + (p.x+s) + " " + (p.y)+ " L" + (p.x) + " " + (p.y+s) +" L" + (p.x-s) + " " + (p.y);
var d = "M"+ (p.x-(Math.sqrt(2)*s))+ " "+ (p.y)+ " L " + (p.x) +" "+ (p.y-(Math.sqrt(2)*s))+ " L" + (p.x+(Math.sqrt(2)*s)) + " " + (p.y)+ " L" + (p.x) + " " + (p.y+(Math.sqrt(2)*s)) +" L" + (p.x-(Math.sqrt(2)*s)) + " " + (p.y);
this._setPath(layer, d);
}
if(shape === "square"){
var d = "M"+ (p.x-s)+ " "+ (p.y-s)+ " L " + (p.x+s) +" "+ (p.y-s)+ " L" + (p.x+s) + " " + (p.y+s)+ " L" + (p.x-s) + " " + (p.y+s) +" L" + (p.x-s) + " " + (p.y-s);
this._setPath(layer, d);
}
if (shape === "triangle" || shape === "triangle-up") {
var d = "M" + (p.x - s) + " " + (p.y + s) + " L" + (p.x) + " " + (p.y - s) + " L" + (p.x + s) + " " + (p.y + s) + " Z";
var d = "M" + (p.x - (13/10*s)) + " " + (p.y + (0.75*s)) + " L" + (p.x) + " " + (p.y - (1.5*s)) + " L" + (p.x + (13/10*s)) + " " + (p.y + (0.75*s)) + " Z";
this._setPath(layer, d);
}
if (shape === "triangle-down") {
var d = "M" + (p.x - s) + " " + (p.y - s) + " L" + (p.x) + " " + (p.y + s) + " L" + (p.x + s) + " " + (p.y - s) + " Z";
var d = "M" + (p.x - (13/10*s)) + " " + (p.y - (0.75*s)) + " L" + (p.x) + " " + (p.y + (1.5*s)) + " L" + (p.x + (13/10*s)) + " " + (p.y - (0.75*s)) + " Z";
this._setPath(layer, d);
}
if (shape === "circle") {
Expand Down
2 changes: 1 addition & 1 deletion dist/leaflet-svg-shape-markers.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions source/SVG.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ L.SVG.include({
var shape = layer.options.shape;

if(shape === "diamond"){
var d = "M"+ (p.x-s)+ " "+ (p.y)+ " L " + (p.x) +" "+ (p.y-s)+ " L" + (p.x+s) + " " + (p.y)+ " L" + (p.x) + " " + (p.y+s) +" L" + (p.x-s) + " " + (p.y);
var d = "M"+ (p.x-(Math.sqrt(2)*s))+ " "+ (p.y)+ " L " + (p.x) +" "+ (p.y-(Math.sqrt(2)*s))+ " L" + (p.x+(Math.sqrt(2)*s)) + " " + (p.y)+ " L" + (p.x) + " " + (p.y+(Math.sqrt(2)*s)) +" L" + (p.x-(Math.sqrt(2)*s)) + " " + (p.y);
this._setPath(layer, d);
}
if(shape === "square"){
var d = "M"+ (p.x-s)+ " "+ (p.y-s)+ " L " + (p.x+s) +" "+ (p.y-s)+ " L" + (p.x+s) + " " + (p.y+s)+ " L" + (p.x-s) + " " + (p.y+s) +" L" + (p.x-s) + " " + (p.y-s);
this._setPath(layer, d);
}
if (shape === "triangle" || shape === "triangle-up") {
var d = "M" + (p.x - s) + " " + (p.y + s) + " L" + (p.x) + " " + (p.y - s) + " L" + (p.x + s) + " " + (p.y + s) + " Z";
var d = "M" + (p.x - (13/10*s)) + " " + (p.y + (0.75*s)) + " L" + (p.x) + " " + (p.y - (1.5*s)) + " L" + (p.x + (13/10*s)) + " " + (p.y + (0.75*s)) + " Z";
this._setPath(layer, d);
}
if (shape === "triangle-down") {
var d = "M" + (p.x - s) + " " + (p.y - s) + " L" + (p.x) + " " + (p.y + s) + " L" + (p.x + s) + " " + (p.y - s) + " Z";
var d = "M" + (p.x - (13/10*s)) + " " + (p.y - (0.75*s)) + " L" + (p.x) + " " + (p.y + (1.5*s)) + " L" + (p.x + (13/10*s)) + " " + (p.y - (0.75*s)) + " Z";
this._setPath(layer, d);
}
if (shape === "circle") {
Expand Down

0 comments on commit 9013820

Please sign in to comment.