Skip to content
Snippets Groups Projects
Commit 3cddb452 authored by L4929's avatar L4929
Browse files

Text box functionality, still not fully functional; Remove zoom control at top...

Text box functionality, still not fully functional; Remove zoom control at top left corner; Add max and min zooms; Non-functional fix to dragging out of bounds
parent 8e349c9e
No related branches found
No related tags found
3 merge requests!21Development,!15Get game creation to user-marker-database-interactions,!10Add text
/*
Do not touch classes with 'leaflet' in them!
They're Leaflet's own classes
*/
body {
margin: 0;
padding: 0;
......@@ -151,16 +156,25 @@ div.login button:hover {
-moz-user-select: text;
-ms-user-select: text;
user-select: text;
pointer-events: auto;
pointer-events: auto;
cursor: auto;
}
.leaflet-tooltip-top:before,
.leaflet-tooltip-bottom:before,
.leaflet-tooltip-left:before,
.leaflet-tooltip-right:before {
pointer-events: auto;
}
/* Editing editable tooltips */
.editable {
cursor: text;
cursor: text; /* the cursor icon doesn't change by default when hovering on top of the text; overriding */
min-width: 120px;
min-height: 18px;
}
/* placeholder text for tooltip */
[contenteditable=true]:empty:before {
content: attr(placeholder);
display: block; /* For Firefox */
......
......@@ -16,12 +16,13 @@ L.Draw.MarkerTextBox = L.Draw.Marker.extend({
options: {
icon: emptyicon,
repeatMode: false,
interactive: true
},
initialize: function (map, options) {
this.type = 'textbox'; // important to have a unique type, so that it won't get mixed up with other elements
this.featureTypeCode = 'textbox';
this.featureTypeCode = 'textbox';
L.Draw.Feature.prototype.initialize.call(this, map, options);
}
}
});
L.DrawToolbar.include ({
......@@ -47,7 +48,7 @@ L.DrawToolbar.include ({
handler: new L.Draw.Marker(map, this.options.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),
title: 'Write text'
}];
......@@ -55,6 +56,13 @@ L.DrawToolbar.include ({
});
class DrawTools extends Component {
constructor(props){
super(props);
this.state = {
geoJSONAll: [] // property for all GeoJSON data in the map
}
}
_onCreated = (e) => {
// check if a drawn polyline has just one point in it
if (e.layerType === 'polyline' && e.layer.getLatLngs().length === 1) {
......@@ -62,13 +70,26 @@ class DrawTools extends Component {
return;
}
// binding text field to textbox
// clicking on tooltip fires the marker's click handler
if (e.layerType === 'textbox') {
e.layer.bindTooltip('<div class="editable" contenteditable="true" placeholder="Type here"></div>', {permanent: true});
e.layer.bindTooltip('<div class="editable" contenteditable="true" placeholder="Click here and type"></div>', {permanent: true, direction: 'center', interactive: true});
}
// turning layer data to geoJSON
// turning layer data to GeoJSON
let layer = e.layer;
let geoJSON = layer.toGeoJSON();
console.log(JSON.stringify(geoJSON, null, 4)); // makes the output readable in the console
this.makeGeoJSON(e.layer);
/* Original GeoJSON code. Uncomment if needed
let geoJSON = layer.toGeoJSON();
console.log(JSON.stringify(geoJSON, null, 4)); // makes the output readable in the console
*/
}
makeGeoJSON = (e) => {
let geoJSON = e.toGeoJSON();
let newAllGeoJSON = this.state.geoJSONAll;
newAllGeoJSON.push(geoJSON);
console.log(JSON.stringify(newAllGeoJSON, null, 4));
this.setState({geoJSONAll: newAllGeoJSON});
}
render() {
......
......@@ -92,9 +92,9 @@ class UserMap extends Component {
minZoom='7'
maxZoom='17'
// onzoomend={this.testers} // getting the zoom level
maxBounds={this.props.bounds}
maxBounds={this.props.bounds} // maxBounds settings don't work for now, for some reason
maxBoundsViscosity='1'
zoomControl={false} /* remove the default zoom control button at the top left corner */>
zoomControl={false} /* remove the default zoom control button at the top left corner */ >
<TileLayer
attribution='&copy; <a href="https://www.maanmittauslaitos.fi/">Maanmittauslaitos</a>'
url={this.props.mapUrl}
......
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