Commit e71b10e5 authored by Tomas Pettersson's avatar Tomas Pettersson 🏸

location fixes for circle

parent f938a0d6
...@@ -177,10 +177,11 @@ ...@@ -177,10 +177,11 @@
this.accordionDiv = STWkit.DomUtil.create('div', 'uk-accordion', this.container); this.accordionDiv = STWkit.DomUtil.create('div', 'uk-accordion', this.container);
var options = {}; var options = {};
var initials = ''; var initials = '';
options['singlebutton'] = true; options['single'] = false;
options['multiplebutton'] = true; options['multiple'] = false;
options['linebutton'] = true; options['line'] = false;
options['areabutton'] = true; options['polygon'] = true;
options['circle'] = true;
options['initials'] = initials; options['initials'] = initials;
var locationid = 'locationCard'; var locationid = 'locationCard';
this.cardMap[locationid] = new STWkit.LocationCard(locationid, 'Specify location', this.accordionDiv, this.lang, this.langData, map, this.forcing, options); this.cardMap[locationid] = new STWkit.LocationCard(locationid, 'Specify location', this.accordionDiv, this.lang, this.langData, map, this.forcing, options);
......
...@@ -112,11 +112,12 @@ var STWkit; ...@@ -112,11 +112,12 @@ var STWkit;
e.stopPropagation(); e.stopPropagation();
return false; return false;
}; };
var initials = (options && options.initials) || ''; var initials = (options && options.hasOwnProperty('initials')) ? options.initials : '';
var showsingle = (options && options.singlebutton) || true; var showsingle = (options && options.hasOwnProperty('single')) ? options.single : true;
var showmultiple = (options && options.multiplebutton) || false; var showmultiple = (options && options.hasOwnProperty('multiple')) ? options.multiple : false;
var showline = (options && options.linebutton) || true; var showpolygon = (options && options.hasOwnProperty('polygon')) ? options.polygon : true;
var showarea = (options && options.areabutton) || true; var showline = (options && options.hasOwnProperty('line')) ? options.line : true;
var showcircle = (options && options.hasOwnProperty('circle')) ? options.circle : false;
var typeLabelGrid = L.DomUtil.create('div', 'uk-grid uk-margin-top', self.locationForm); var typeLabelGrid = L.DomUtil.create('div', 'uk-grid uk-margin-top', self.locationForm);
var objectlabelDiv = L.DomUtil.create('div', 'uk-width-1-2', typeLabelGrid); var objectlabelDiv = L.DomUtil.create('div', 'uk-width-1-2', typeLabelGrid);
_super.prototype.addLabelDiv.call(_this, objectlabelDiv, "Outlet type", "See more information <a style='color:#faa732;' href='help/classic/#oil-oo-type' target='_blank'>here</a>"); _super.prototype.addLabelDiv.call(_this, objectlabelDiv, "Outlet type", "See more information <a style='color:#faa732;' href='help/classic/#oil-oo-type' target='_blank'>here</a>");
...@@ -135,19 +136,24 @@ var STWkit; ...@@ -135,19 +136,24 @@ var STWkit;
self.multipleButton.disabled = false; self.multipleButton.disabled = false;
if (!showmultiple) if (!showmultiple)
self.multipleButton.style.display = 'none'; self.multipleButton.style.display = 'none';
self.circleButton = L.DomUtil.create('button', 'uk-button uk-button-small', objectButtonGroup);
self.circleButton.textContent = 'Circle';
if (!showcircle)
self.circleButton.style.display = 'none';
self.lineButton = L.DomUtil.create('button', 'uk-button uk-button-small', objectButtonGroup); self.lineButton = L.DomUtil.create('button', 'uk-button uk-button-small', objectButtonGroup);
self.lineButton.textContent = 'Line'; self.lineButton.textContent = 'Line';
self.lineButton.disabled = false; self.lineButton.disabled = false;
if (!showline) if (!showline)
self.lineButton.style.display = 'none'; self.lineButton.style.display = 'none';
self.polygonButton = L.DomUtil.create('button', 'uk-button uk-button-small', objectButtonGroup); self.polygonButton = L.DomUtil.create('button', 'uk-button uk-button-small', objectButtonGroup);
self.polygonButton.textContent = 'Area'; self.polygonButton.textContent = 'Polygon';
if (!showarea) if (!showpolygon)
self.polygonButton.style.display = 'none'; self.polygonButton.style.display = 'none';
self.pointButton.onclick = function () { self.geometryType = "point"; self.control.setType(self.geometryType); }; self.pointButton.onclick = function () { self.geometryType = "point"; self.control.setType(self.geometryType); };
self.lineButton.onclick = function () { self.geometryType = "linestring"; self.control.setType(self.geometryType); }; self.lineButton.onclick = function () { self.geometryType = "linestring"; self.control.setType(self.geometryType); };
self.multipleButton.onclick = function () { self.geometryType = "multipoint"; self.control.setType(self.geometryType); }; self.multipleButton.onclick = function () { self.geometryType = "multipoint"; self.control.setType(self.geometryType); };
self.polygonButton.onclick = function () { self.geometryType = "polygon"; self.control.setType(self.geometryType); }; self.polygonButton.onclick = function () { self.geometryType = "polygon"; self.control.setType(self.geometryType); };
self.circleButton.onclick = function () { self.geometryType = "circle"; self.control.setType(self.geometryType); };
self.polygonButton.disabled = false; self.polygonButton.disabled = false;
self.hasPosition = false; self.hasPosition = false;
function validate() { function validate() {
...@@ -221,6 +227,9 @@ var STWkit; ...@@ -221,6 +227,9 @@ var STWkit;
case 'point': case 'point':
coordinates.push([latlngs[0][0].lng, latlngs[0][0].lat, 0]); coordinates.push([latlngs[0][0].lng, latlngs[0][0].lat, 0]);
break; break;
case 'circle':
coordinates.push([latlngs[0][0].lng, latlngs[0][0].lat, 0]);
break;
case 'multipoint': case 'multipoint':
coordinates = geojson.features[0].geometry.coordinates; coordinates = geojson.features[0].geometry.coordinates;
for (var i = 0; i < coordinates.length; i++) { for (var i = 0; i < coordinates.length; i++) {
...@@ -247,7 +256,7 @@ var STWkit; ...@@ -247,7 +256,7 @@ var STWkit;
} }
}); });
var content = self.control.onAdd(map); var content = self.control.onAdd(map);
var coordinateDiv = L.DomUtil.create('div', 'uk-margin-top uk-margin-bottom', self.locationDiv); var coordinateDiv = L.DomUtil.create('div', 'uk-margin-top uk-margin-bottom', self.locationForm);
coordinateDiv.appendChild(content); coordinateDiv.appendChild(content);
self.control.hideTable(); self.control.hideTable();
latlngButton.onclick = function () { self.control.latlng(); }; latlngButton.onclick = function () { self.control.latlng(); };
...@@ -327,17 +336,24 @@ var STWkit; ...@@ -327,17 +336,24 @@ var STWkit;
}; };
LocationCard.prototype.defaults = function () { LocationCard.prototype.defaults = function () {
var self = this; var self = this;
if (document.body.contains(self.pointButton)) if (document.body.contains(self.pointButton) && self.pointButton.style.display != 'none')
self.pointButton.click(); self.pointButton.click();
else if (document.body.contains(self.circleButton) && self.circleButton.style.display != 'none')
self.circleButton.click();
}; };
LocationCard.prototype.populateCard = function (geojson) { LocationCard.prototype.populateCard = function (geojson) {
var self = this; var self = this;
var simulation = geojson.features[0].properties.simulation; var simulation = geojson.features[0].properties.simulation;
var type = geojson.features[0].geometry.type.toLowerCase(); var type = geojson.features[0].geometry.type.toLowerCase();
if (geojson.features[0].properties.hasOwnProperty('radius'))
type = 'circle';
switch (type) { switch (type) {
case "point": case "point":
self.pointButton.click(); self.pointButton.click();
break; break;
case "circle":
self.circleButton.click();
break;
case "multipoint": case "multipoint":
self.multipleButton.click(); self.multipleButton.click();
break; break;
......
This diff is collapsed.
...@@ -100,6 +100,7 @@ module STWkit { ...@@ -100,6 +100,7 @@ module STWkit {
public polygonButton: HTMLButtonElement; public polygonButton: HTMLButtonElement;
public multipleButton: HTMLButtonElement; public multipleButton: HTMLButtonElement;
public pointButton: HTMLButtonElement; public pointButton: HTMLButtonElement;
public circleButton: HTMLButtonElement;
public lineButton: HTMLButtonElement; public lineButton: HTMLButtonElement;
public exitControl: L.Control; public exitControl: L.Control;
public dateFormat: string; public dateFormat: string;
...@@ -137,11 +138,12 @@ module STWkit { ...@@ -137,11 +138,12 @@ module STWkit {
e.stopPropagation(); e.stopPropagation();
return false; return false;
}; };
var initials = (options && options.initials) || ''; var initials = (options && options.hasOwnProperty('initials'))?options.initials:'';
var showsingle = (options && options.singlebutton) || true; var showsingle = (options && options.hasOwnProperty('single'))?options.single:true;
var showmultiple = (options && options.multiplebutton) || false; var showmultiple = (options && options.hasOwnProperty('multiple'))?options.multiple:false;
var showline = (options && options.linebutton) || true; var showpolygon = (options && options.hasOwnProperty('polygon'))?options.polygon:true;
var showarea = (options && options.areabutton) || true; var showline = (options && options.hasOwnProperty('line'))?options.line:true;
var showcircle = (options && options.hasOwnProperty('circle'))?options.circle:false;
var typeLabelGrid = <HTMLDivElement>L.DomUtil.create('div', 'uk-grid uk-margin-top', self.locationForm); var typeLabelGrid = <HTMLDivElement>L.DomUtil.create('div', 'uk-grid uk-margin-top', self.locationForm);
var objectlabelDiv = <HTMLDivElement>L.DomUtil.create('div', 'uk-width-1-2', typeLabelGrid); var objectlabelDiv = <HTMLDivElement>L.DomUtil.create('div', 'uk-width-1-2', typeLabelGrid);
super.addLabelDiv(objectlabelDiv, "Outlet type", "See more information <a style='color:#faa732;' href='help/classic/#oil-oo-type' target='_blank'>here</a>"); super.addLabelDiv(objectlabelDiv, "Outlet type", "See more information <a style='color:#faa732;' href='help/classic/#oil-oo-type' target='_blank'>here</a>");
...@@ -158,17 +160,21 @@ module STWkit { ...@@ -158,17 +160,21 @@ module STWkit {
self.multipleButton.textContent = 'Multiple'; self.multipleButton.textContent = 'Multiple';
self.multipleButton.disabled = false; self.multipleButton.disabled = false;
if (!showmultiple) self.multipleButton.style.display = 'none'; if (!showmultiple) self.multipleButton.style.display = 'none';
self.circleButton = <HTMLButtonElement>L.DomUtil.create('button', 'uk-button uk-button-small', objectButtonGroup);
self.circleButton.textContent = 'Circle';
if (!showcircle) self.circleButton.style.display = 'none';
self.lineButton = <HTMLButtonElement>L.DomUtil.create('button', 'uk-button uk-button-small', objectButtonGroup); self.lineButton = <HTMLButtonElement>L.DomUtil.create('button', 'uk-button uk-button-small', objectButtonGroup);
self.lineButton.textContent = 'Line'; self.lineButton.textContent = 'Line';
self.lineButton.disabled = false; self.lineButton.disabled = false;
if (!showline) self.lineButton.style.display = 'none'; if (!showline) self.lineButton.style.display = 'none';
self.polygonButton = <HTMLButtonElement>L.DomUtil.create('button', 'uk-button uk-button-small', objectButtonGroup); self.polygonButton = <HTMLButtonElement>L.DomUtil.create('button', 'uk-button uk-button-small', objectButtonGroup);
self.polygonButton.textContent = 'Area'; self.polygonButton.textContent = 'Polygon';
if (!showarea) self.polygonButton.style.display = 'none'; if (!showpolygon) self.polygonButton.style.display = 'none';
self.pointButton.onclick = function () { self.geometryType = "point"; self.control.setType(self.geometryType); } self.pointButton.onclick = function () { self.geometryType = "point"; self.control.setType(self.geometryType); }
self.lineButton.onclick = function () { self.geometryType = "linestring"; self.control.setType(self.geometryType); } self.lineButton.onclick = function () { self.geometryType = "linestring"; self.control.setType(self.geometryType); }
self.multipleButton.onclick = function () { self.geometryType = "multipoint"; self.control.setType(self.geometryType); } self.multipleButton.onclick = function () { self.geometryType = "multipoint"; self.control.setType(self.geometryType); }
self.polygonButton.onclick = function () { self.geometryType = "polygon"; self.control.setType(self.geometryType); } self.polygonButton.onclick = function () { self.geometryType = "polygon"; self.control.setType(self.geometryType); }
self.circleButton.onclick = function () { self.geometryType = "circle"; self.control.setType(self.geometryType); }
self.polygonButton.disabled = false; self.polygonButton.disabled = false;
self.hasPosition = false; self.hasPosition = false;
...@@ -245,6 +251,9 @@ module STWkit { ...@@ -245,6 +251,9 @@ module STWkit {
case 'point': case 'point':
coordinates.push([latlngs[0][0].lng, latlngs[0][0].lat, 0]); coordinates.push([latlngs[0][0].lng, latlngs[0][0].lat, 0]);
break; break;
case 'circle':
coordinates.push([latlngs[0][0].lng, latlngs[0][0].lat, 0]);
break;
case 'multipoint': case 'multipoint':
coordinates = geojson.features[0].geometry.coordinates; coordinates = geojson.features[0].geometry.coordinates;
for (var i = 0; i < coordinates.length; i++) {coordinates[i].push(0);} for (var i = 0; i < coordinates.length; i++) {coordinates[i].push(0);}
...@@ -269,7 +278,7 @@ module STWkit { ...@@ -269,7 +278,7 @@ module STWkit {
} }
}); });
var content = self.control.onAdd(map); var content = self.control.onAdd(map);
var coordinateDiv = <HTMLDivElement>L.DomUtil.create('div', 'uk-margin-top uk-margin-bottom', self.locationDiv); var coordinateDiv = <HTMLDivElement>L.DomUtil.create('div', 'uk-margin-top uk-margin-bottom', self.locationForm);
coordinateDiv.appendChild(content); coordinateDiv.appendChild(content);
self.control.hideTable(); self.control.hideTable();
...@@ -356,17 +365,22 @@ module STWkit { ...@@ -356,17 +365,22 @@ module STWkit {
public defaults() { public defaults() {
var self = this; var self = this;
if (document.body.contains(self.pointButton)) self.pointButton.click(); if (document.body.contains(self.pointButton) && self.pointButton.style.display != 'none') self.pointButton.click();
else if (document.body.contains(self.circleButton) && self.circleButton.style.display != 'none') self.circleButton.click();
} }
public populateCard(geojson) { public populateCard(geojson) {
var self = this; var self = this;
var simulation = geojson.features[0].properties.simulation; var simulation = geojson.features[0].properties.simulation;
var type = geojson.features[0].geometry.type.toLowerCase(); var type = geojson.features[0].geometry.type.toLowerCase();
if (geojson.features[0].properties.hasOwnProperty('radius')) type = 'circle';
switch (type) { switch (type) {
case "point": case "point":
self.pointButton.click(); self.pointButton.click();
break; break;
case "circle":
self.circleButton.click();
break;
case "multipoint": case "multipoint":
self.multipleButton.click(); self.multipleButton.click();
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment