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

Can now delete text box by clicking on tooltip. Also cleaned some code

parent 6a7997ef
No related branches found
No related tags found
3 merge requests!21Development,!15Get game creation to user-marker-database-interactions,!10Add text
...@@ -148,13 +148,6 @@ div.login button:hover { ...@@ -148,13 +148,6 @@ div.login button:hover {
/* Editing tooltips */ /* Editing tooltips */
.leaflet-tooltip { .leaflet-tooltip {
font-size: 18px; font-size: 18px;
/* by default leaflet doesn't allow selecting content in tooltips; overriding */
-webkit-user-select: text;
-moz-user-select: text;
-ms-user-select: text;
user-select: text;
pointer-events: all;
cursor: auto;
/* Overriding tooltip layout by making it invisible */ /* Overriding tooltip layout by making it invisible */
background-color: transparent; background-color: transparent;
box-shadow: none; box-shadow: none;
...@@ -162,10 +155,7 @@ div.login button:hover { ...@@ -162,10 +155,7 @@ div.login button:hover {
padding: 0; padding: 0;
} }
.leaflet-clickable { /* remove the small triangle on tooltip */
pointer-events: all;
}
.leaflet-tooltip-bottom:before { .leaflet-tooltip-bottom:before {
border: 0; border: 0;
} }
......
...@@ -8,7 +8,7 @@ import { FeatureGroup } from "react-leaflet"; ...@@ -8,7 +8,7 @@ import { FeatureGroup } from "react-leaflet";
L.Draw.MarkerTextBox = L.Draw.Marker.extend({ L.Draw.MarkerTextBox = L.Draw.Marker.extend({
options: { options: {
icon: L.divIcon({ icon: L.divIcon({
className: "dummy", className: "", // empty class to override default styling
iconSize: [20, 20], iconSize: [20, 20],
iconAnchor: [10, 20] iconAnchor: [10, 20]
}), }),
...@@ -23,7 +23,7 @@ L.Draw.MarkerTextBox = L.Draw.Marker.extend({ ...@@ -23,7 +23,7 @@ L.Draw.MarkerTextBox = L.Draw.Marker.extend({
}); });
// Overriding default toolbar // Overriding default toolbar
// Just adding one new button, though, lol // Just adding one new button though lol
L.DrawToolbar.include({ L.DrawToolbar.include({
getModeHandlers: function(map) { getModeHandlers: function(map) {
return [ return [
...@@ -88,10 +88,15 @@ class DrawTools extends Component { ...@@ -88,10 +88,15 @@ class DrawTools extends Component {
interactive: true interactive: true
}); });
// disable dragging when mousedown is active on top of marker (tooltip) // disable dragging when cursor is over marker (tooltip)
// clicking on tooltip fires the marker's click handler, hence e.layer.on // clicking on tooltip fires the marker's click handler, hence e.layer.on
e.layer.on("mousedown", function() { e.layer.on("mouseover", function() {
L.DomEvent.disableClickPropagation(tooltip); e.layer._map.dragging.disable();
});
// enable dragging again when cursor is out of marker (tooltip)
e.layer.on("mouseout", function() {
e.layer._map.dragging.enable();
}); });
// show placeholder text again upon emptying textbox // show placeholder text again upon emptying textbox
...@@ -107,33 +112,12 @@ class DrawTools extends Component { ...@@ -107,33 +112,12 @@ class DrawTools extends Component {
tooltip.innerHTML = tooltip.innerHTML =
'<div placeholder="Click here and type" contenteditable="true"></div>'; '<div placeholder="Click here and type" contenteditable="true"></div>';
} }
console.log(tooltip.firstChild.childNodes.length);
let margintop = tooltip.firstChild.childNodes.length * 40;
console.log(e.layer);
//tooltip.style.marginTop = margintop.toString() + "px";
/*
let editable = document.querySelector(".editable");
let editableStyle = getComputedStyle(editable);
let horizontalLoc = parseInt(editableStyle.height.replace("px", ""));
let verticalLoc = parseInt(editableStyle.width.replace("px", ""));
let trueHorizontalLoc = horizontalLoc + 40;
let trueVerticalLoc = verticalLoc + 10;
tooltip.style.marginTop = horizontalLoc.toString() + "px";
*/
/*
editable.firstChild.style.marginTop = toString(
trueHorizontalLoc + "px"
);
console.log("editable.firstChild.style: ");
console.log(editable.firstChild.style);
*/
}); });
} } // end if (e.layerType === "textbox")
// turning layer data to GeoJSON // turning layer data to GeoJSON
this.makeGeoJSON(e.layer); this.makeGeoJSON(e.layer);
}; }; // end _onCreated
makeGeoJSON = e => { makeGeoJSON = e => {
let geoJSON = e.toGeoJSON(); let geoJSON = e.toGeoJSON();
......
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