Skip to content
Snippets Groups Projects
Commit 1c8b7bdb authored by L4929's avatar L4929
Browse files

Button actually looks legit!

parent 6724bca6
No related branches found
No related tags found
3 merge requests!21Development,!15Get game creation to user-marker-database-interactions,!10Add text
...@@ -138,3 +138,9 @@ div.login button:hover { ...@@ -138,3 +138,9 @@ div.login button:hover {
background-color: darkblue; background-color: darkblue;
cursor: pointer; cursor: pointer;
} }
/* Editing text button in the toolbar */
.leaflet-draw-toolbar .leaflet-draw-draw-textbox {
background-image: url('icons/button-textbox.png');
background-size: 30px 30px;
}
\ No newline at end of file
import React, {Component} from 'react'; import React, {Component} from 'react';
import { EditControl } from 'react-leaflet-draw' import { EditControl } from 'react-leaflet-draw'
import L from 'leaflet' import L from 'leaflet'
import 'leaflet-draw'
import { FeatureGroup } from 'react-leaflet' import { FeatureGroup } from 'react-leaflet'
// empty icon for the text field // empty icon for the text field
...@@ -19,9 +20,9 @@ L.Draw.MarkerTextBox = L.Draw.Marker.extend({ ...@@ -19,9 +20,9 @@ L.Draw.MarkerTextBox = L.Draw.Marker.extend({
initialize: function (map, options) { initialize: function (map, options) {
// important to have a unique type, so that it won't get mixed up with other elements // important to have a unique type, so that it won't get mixed up with other elements
this.type = 'textbox'; this.type = 'textbox';
this.featureTypeCode = 'textbox'; this.featureTypeCode = 'textbox';
L.Draw.Feature.prototype.initialize.call(this, map, options); L.Draw.Feature.prototype.initialize.call(this, map, options);
} }
}); });
//Redefinitions d'éléments de DrawToolbar //Redefinitions d'éléments de DrawToolbar
...@@ -58,7 +59,7 @@ L.DrawToolbar.include ({ ...@@ -58,7 +59,7 @@ L.DrawToolbar.include ({
handler: new L.Draw.Marker(map, this.options.marker), handler: new L.Draw.Marker(map, this.options.marker),
title: L.drawLocal.draw.toolbar.buttons.marker title: L.drawLocal.draw.toolbar.buttons.marker
},{ },{
enabled: this.options.marker, enabled: this.options.marker,
handler: new L.Draw.MarkerTextBox(map, this.options.marker), handler: new L.Draw.MarkerTextBox(map, this.options.marker),
title: 'Write text' title: 'Write text'
}]; }];
...@@ -72,11 +73,10 @@ class DrawTools extends Component { ...@@ -72,11 +73,10 @@ class DrawTools extends Component {
e.layer.remove(); e.layer.remove();
return; return;
} }
if (e.layerType === 'marker') { if (e.layerType === 'textbox') {
e.layer.bindTooltip('say hello to mr. akers'); e.layer.bindTooltip('say hello to mr. akers', {permanent: true});
} }
let type = e.layerType; // from the example; isn't used right now, but may be relevant in the future let layer = e.layer;
let layer = e.layer;
let geoJSON = layer.toGeoJSON(); let geoJSON = layer.toGeoJSON();
console.log(JSON.stringify(geoJSON, null, 4)); // makes the output readable in the console console.log(JSON.stringify(geoJSON, null, 4)); // makes the output readable in the console
} }
......
src/icons/button-textbox.png

793 B

src/icons/nil.png

564 B

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment