fix colour setting, broken by my changes to #746
This commit is contained in:
parent
af491221dc
commit
dbfaf19b91
@ -32,12 +32,11 @@ window.plugin.drawTools.loadExternals = function() {
|
|||||||
$('head').append('<style>@@INCLUDESTRING:external/leaflet.draw.css@@</style>');
|
$('head').append('<style>@@INCLUDESTRING:external/leaflet.draw.css@@</style>');
|
||||||
}
|
}
|
||||||
|
|
||||||
window.plugin.drawTools.setOptions = function(color) {
|
window.plugin.drawTools.setOptions = function() {
|
||||||
if (color === undefined) color = '#a24ac3';
|
|
||||||
|
|
||||||
window.plugin.drawTools.lineOptions = {
|
window.plugin.drawTools.lineOptions = {
|
||||||
stroke: true,
|
stroke: true,
|
||||||
color: color,
|
color: '#a24ac3',
|
||||||
weight: 4,
|
weight: 4,
|
||||||
opacity: 0.5,
|
opacity: 0.5,
|
||||||
fill: false,
|
fill: false,
|
||||||
@ -61,6 +60,14 @@ window.plugin.drawTools.setOptions = function(color) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window.plugin.drawTools.setDrawColor = function(color) {
|
||||||
|
|
||||||
|
window.plugin.drawTools.drawControl.setDrawingOptions({
|
||||||
|
'polygon': { 'shapeOptions': { color: color } },
|
||||||
|
'polyline': { 'shapeOptions': { color: color } },
|
||||||
|
'circle': { 'shapeOptions': { color: color } },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// renders the draw control buttons in the top left corner
|
// renders the draw control buttons in the top left corner
|
||||||
window.plugin.drawTools.addDrawControl = function() {
|
window.plugin.drawTools.addDrawControl = function() {
|
||||||
@ -126,6 +133,8 @@ window.plugin.drawTools.addDrawControl = function() {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
window.plugin.drawTools.drawControl = drawControl;
|
||||||
|
|
||||||
map.addControl(drawControl);
|
map.addControl(drawControl);
|
||||||
// plugin.drawTools.addCustomButtons();
|
// plugin.drawTools.addCustomButtons();
|
||||||
}
|
}
|
||||||
@ -194,22 +203,21 @@ window.plugin.drawTools.load = function() {
|
|||||||
var data = JSON.parse(dataStr);
|
var data = JSON.parse(dataStr);
|
||||||
$.each(data, function(index,item) {
|
$.each(data, function(index,item) {
|
||||||
var layer = null;
|
var layer = null;
|
||||||
|
var extraOpt = {};
|
||||||
|
if (item.color) extraOpt.color = item.color;
|
||||||
|
|
||||||
switch(item.type) {
|
switch(item.type) {
|
||||||
case 'polyline':
|
case 'polyline':
|
||||||
window.plugin.drawTools.setOptions(item.color);
|
layer = L.geodesicPolyline(item.latLngs, L.extend({},window.plugin.drawTools.lineOptions,extraOpt));
|
||||||
layer = L.geodesicPolyline(item.latLngs,window.plugin.drawTools.lineOptions);
|
|
||||||
break;
|
break;
|
||||||
case 'polygon':
|
case 'polygon':
|
||||||
window.plugin.drawTools.setOptions(item.color);
|
layer = L.geodesicPolygon(item.latLngs, L.extend({},window.plugin.drawTools.polygonOptions,extraOpt));
|
||||||
layer = L.geodesicPolygon(item.latLngs,window.plugin.drawTools.polygonOptions);
|
|
||||||
break;
|
break;
|
||||||
case 'circle':
|
case 'circle':
|
||||||
window.plugin.drawTools.setOptions(item.color);
|
layer = L.geodesicCircle(item.latLng, item.radius, L.extend({},window.plugin.drawTools.polygonOptions,extraOpt));
|
||||||
layer = L.geodesicCircle(item.latLng,item.radius,window.plugin.drawTools.polygonOptions);
|
|
||||||
break;
|
break;
|
||||||
case 'marker':
|
case 'marker':
|
||||||
// TODO? marker colours
|
layer = L.marker(item.latLng, window.plugin.drawTools.markerOptions);
|
||||||
layer = L.marker(item.latLng,window.plugin.drawTools.markerOptions)
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
console.warn('unknown layer type "'+item.type+'" when loading draw tools layer');
|
console.warn('unknown layer type "'+item.type+'" when loading draw tools layer');
|
||||||
@ -273,7 +281,7 @@ window.plugin.drawTools.optReset = function() {
|
|||||||
window.plugin.drawTools.optColor = function() {
|
window.plugin.drawTools.optColor = function() {
|
||||||
var promptAction = prompt('Current Color is '+window.plugin.drawTools.lineOptions.color, '');
|
var promptAction = prompt('Current Color is '+window.plugin.drawTools.lineOptions.color, '');
|
||||||
if(promptAction !== null && promptAction !== '') {
|
if(promptAction !== null && promptAction !== '') {
|
||||||
window.plugin.drawTools.setOptions(promptAction);
|
window.plugin.drawTools.setDrawColor(promptAction);
|
||||||
console.log('DRAWTOOLS: color changed');
|
console.log('DRAWTOOLS: color changed');
|
||||||
window.plugin.drawTools.optAlert('Color Changed. ');
|
window.plugin.drawTools.optAlert('Color Changed. ');
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user