Merge branch 'pull_request/draw-marker-colors' of https://github.com/strguntbr/ingress-intel-total-conversion into strguntbr-pull_request/draw-marker-colors
This commit is contained in:
commit
fcb1217517
12
images/marker-icon.svg.template
Normal file
12
images/marker-icon.svg.template
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg"
|
||||||
|
version="1.1" baseProfile="full"
|
||||||
|
width="25px" height="41px" viewBox="0 0 25 41">
|
||||||
|
|
||||||
|
<path d="M1.36241844765,18.67488124675 A12.5,12.5 0 1,1 23.63758155235,18.67488124675 L12.5,40.5336158073 Z" style="stroke:none; fill: %COLOR%;" />
|
||||||
|
<path d="M1.80792170975,18.44788599685 A12,12 0 1,1 23.19207829025,18.44788599685 L12.5,39.432271175 Z" style="stroke:#000000; stroke-width:1px; stroke-opacity: 0.15; fill: none;" />
|
||||||
|
<path d="M2.921679865,17.8803978722 A10.75,10.75 0 1,1 22.078320135,17.8803978722 L12.5,36.6789095943 Z" style="stroke:#ffffff; stroke-width:1.5px; stroke-opacity: 0.35; fill: none;" />
|
||||||
|
|
||||||
|
<path d="M19.86121593215,17.25 L12.5,21.5 L5.13878406785,17.25 L5.13878406785,8.75 L12.5,4.5 L19.86121593215,8.75 Z M7.7368602792,10.25 L17.2631397208,10.25 L12.5,18.5 Z M12.5,13 L7.7368602792,10.25 M12.5,13 L17.2631397208,10.25 M12.5,13 L12.5,18.5 M19.86121593215,17.25 L16.39711431705,15.25 M5.13878406785,17.25 L8.60288568295,15.25 M12.5,4.5 L12.5,8.5" style="stroke:#ffffff; stroke-width:1.25px; stroke-opacity: 1; fill: none;" />
|
||||||
|
|
||||||
|
</svg>
|
After Width: | Height: | Size: 1.1 KiB |
@ -34,8 +34,28 @@ window.plugin.drawTools.loadExternals = function() {
|
|||||||
$('head').append('<style>@@INCLUDESTRING:external/spectrum/spectrum.css@@</style>');
|
$('head').append('<style>@@INCLUDESTRING:external/spectrum/spectrum.css@@</style>');
|
||||||
}
|
}
|
||||||
|
|
||||||
window.plugin.drawTools.currentColor = '#a24ac3';
|
window.plugin.drawTools.getMarkerIcon = function(color) {
|
||||||
|
if (typeof(color) === 'undefined') {
|
||||||
|
console.warn('Color is not set or not a valid color. Using default color as fallback.');
|
||||||
|
color = '#a24ac3';
|
||||||
|
}
|
||||||
|
|
||||||
|
var svgIcon = window.plugin.drawTools.markerTemplate.replace(/%COLOR%/g, color);
|
||||||
|
|
||||||
|
return L.divIcon({
|
||||||
|
iconSize: new L.Point(25, 41),
|
||||||
|
iconAnchor: new L.Point(12, 41),
|
||||||
|
html: svgIcon,
|
||||||
|
className: 'leaflet-iitc-custom-icon',
|
||||||
|
// L.divIcon does not use the option color, but we store it here to
|
||||||
|
// be able to simply retrieve the color for serializing markers
|
||||||
|
color: color
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
window.plugin.drawTools.currentColor = '#a24ac3';
|
||||||
|
window.plugin.drawTools.markerTemplate = '@@INCLUDESTRING:images/marker-icon.svg.template@@';
|
||||||
|
window.plugin.drawTools.currentMarker = window.plugin.drawTools.getMarkerIcon(window.plugin.drawTools.currentColor);
|
||||||
|
|
||||||
window.plugin.drawTools.setOptions = function() {
|
window.plugin.drawTools.setOptions = function() {
|
||||||
|
|
||||||
@ -60,7 +80,7 @@ window.plugin.drawTools.setOptions = function() {
|
|||||||
delete window.plugin.drawTools.editOptions.color;
|
delete window.plugin.drawTools.editOptions.color;
|
||||||
|
|
||||||
window.plugin.drawTools.markerOptions = {
|
window.plugin.drawTools.markerOptions = {
|
||||||
icon: new L.Icon.Default(),
|
icon: window.plugin.drawTools.currentMarker,
|
||||||
zIndexOffset: 2000
|
zIndexOffset: 2000
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -68,11 +88,13 @@ window.plugin.drawTools.setOptions = function() {
|
|||||||
|
|
||||||
window.plugin.drawTools.setDrawColor = function(color) {
|
window.plugin.drawTools.setDrawColor = function(color) {
|
||||||
window.plugin.drawTools.currentColor = color;
|
window.plugin.drawTools.currentColor = color;
|
||||||
|
window.plugin.drawTools.currentMarker = window.plugin.drawTools.getMarkerIcon(color);
|
||||||
|
|
||||||
window.plugin.drawTools.drawControl.setDrawingOptions({
|
window.plugin.drawTools.drawControl.setDrawingOptions({
|
||||||
'polygon': { 'shapeOptions': { color: color } },
|
'polygon': { 'shapeOptions': { color: color } },
|
||||||
'polyline': { 'shapeOptions': { color: color } },
|
'polyline': { 'shapeOptions': { color: color } },
|
||||||
'circle': { 'shapeOptions': { color: color } },
|
'circle': { 'shapeOptions': { color: color } },
|
||||||
|
'marker': { 'icon': window.plugin.drawTools.currentMarker },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,14 +135,15 @@ window.plugin.drawTools.addDrawControl = function() {
|
|||||||
snapPoint: window.plugin.drawTools.getSnapLatLng,
|
snapPoint: window.plugin.drawTools.getSnapLatLng,
|
||||||
},
|
},
|
||||||
|
|
||||||
marker: {
|
// Options for marker (icon, zIndexOffset) are not set via shapeOptions,
|
||||||
|
// so we have merge them here!
|
||||||
|
marker: L.extend({}, window.plugin.drawTools.markerOptions, {
|
||||||
title: 'Add a marker.\n\n'
|
title: 'Add a marker.\n\n'
|
||||||
+ 'Click on the button, then click on the map where\n'
|
+ 'Click on the button, then click on the map where\n'
|
||||||
+ 'you want the marker to appear.',
|
+ 'you want the marker to appear.',
|
||||||
shapeOptions: window.plugin.drawTools.markerOptions,
|
|
||||||
snapPoint: window.plugin.drawTools.getSnapLatLng,
|
snapPoint: window.plugin.drawTools.getSnapLatLng,
|
||||||
repeatMode: true,
|
repeatMode: true
|
||||||
},
|
}),
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -190,6 +213,7 @@ window.plugin.drawTools.save = function() {
|
|||||||
} else if (layer instanceof L.Marker) {
|
} else if (layer instanceof L.Marker) {
|
||||||
item.type = 'marker';
|
item.type = 'marker';
|
||||||
item.latLng = layer.getLatLng();
|
item.latLng = layer.getLatLng();
|
||||||
|
item.color = layer.options.icon.options.color;
|
||||||
} else {
|
} else {
|
||||||
console.warn('Unknown layer type when saving draw tools layer');
|
console.warn('Unknown layer type when saving draw tools layer');
|
||||||
return; //.eachLayer 'continue'
|
return; //.eachLayer 'continue'
|
||||||
@ -233,7 +257,9 @@ window.plugin.drawTools.import = function(data) {
|
|||||||
layer = L.geodesicCircle(item.latLng, item.radius, L.extend({},window.plugin.drawTools.polygonOptions,extraOpt));
|
layer = L.geodesicCircle(item.latLng, item.radius, L.extend({},window.plugin.drawTools.polygonOptions,extraOpt));
|
||||||
break;
|
break;
|
||||||
case 'marker':
|
case 'marker':
|
||||||
layer = L.marker(item.latLng, window.plugin.drawTools.markerOptions);
|
var extraMarkerOpt = {};
|
||||||
|
if (item.color) extraMarkerOpt.icon = window.plugin.drawTools.getMarkerIcon(item.color);
|
||||||
|
layer = L.marker(item.latLng, L.extend({},window.plugin.drawTools.markerOptions,extraMarkerOpt));
|
||||||
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');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user