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

location fixes for circle

parent f938a0d6
......@@ -177,10 +177,11 @@
this.accordionDiv = STWkit.DomUtil.create('div', 'uk-accordion', this.container);
var options = {};
var initials = '';
options['singlebutton'] = true;
options['multiplebutton'] = true;
options['linebutton'] = true;
options['areabutton'] = true;
options['single'] = false;
options['multiple'] = false;
options['line'] = false;
options['polygon'] = true;
options['circle'] = true;
options['initials'] = initials;
var locationid = 'locationCard';
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;
e.stopPropagation();
return false;
};
var initials = (options && options.initials) || '';
var showsingle = (options && options.singlebutton) || true;
var showmultiple = (options && options.multiplebutton) || false;
var showline = (options && options.linebutton) || true;
var showarea = (options && options.areabutton) || true;
var initials = (options && options.hasOwnProperty('initials')) ? options.initials : '';
var showsingle = (options && options.hasOwnProperty('single')) ? options.single : true;
var showmultiple = (options && options.hasOwnProperty('multiple')) ? options.multiple : false;
var showpolygon = (options && options.hasOwnProperty('polygon')) ? options.polygon : 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 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>");
......@@ -135,19 +136,24 @@ var STWkit;
self.multipleButton.disabled = false;
if (!showmultiple)
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.textContent = 'Line';
self.lineButton.disabled = false;
if (!showline)
self.lineButton.style.display = 'none';
self.polygonButton = L.DomUtil.create('button', 'uk-button uk-button-small', objectButtonGroup);
self.polygonButton.textContent = 'Area';
if (!showarea)
self.polygonButton.textContent = 'Polygon';
if (!showpolygon)
self.polygonButton.style.display = 'none';
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.multipleButton.onclick = function () { self.geometryType = "multipoint"; 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.hasPosition = false;
function validate() {
......@@ -221,6 +227,9 @@ var STWkit;
case 'point':
coordinates.push([latlngs[0][0].lng, latlngs[0][0].lat, 0]);
break;
case 'circle':
coordinates.push([latlngs[0][0].lng, latlngs[0][0].lat, 0]);
break;
case 'multipoint':
coordinates = geojson.features[0].geometry.coordinates;
for (var i = 0; i < coordinates.length; i++) {
......@@ -247,7 +256,7 @@ var STWkit;
}
});
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);
self.control.hideTable();
latlngButton.onclick = function () { self.control.latlng(); };
......@@ -327,17 +336,24 @@ var STWkit;
};
LocationCard.prototype.defaults = function () {
var self = this;
if (document.body.contains(self.pointButton))
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();
};
LocationCard.prototype.populateCard = function (geojson) {
var self = this;
var simulation = geojson.features[0].properties.simulation;
var type = geojson.features[0].geometry.type.toLowerCase();
if (geojson.features[0].properties.hasOwnProperty('radius'))
type = 'circle';
switch (type) {
case "point":
self.pointButton.click();
break;
case "circle":
self.circleButton.click();
break;
case "multipoint":
self.multipleButton.click();
break;
......
This diff is collapsed.
......@@ -100,6 +100,7 @@ module STWkit {
public polygonButton: HTMLButtonElement;
public multipleButton: HTMLButtonElement;
public pointButton: HTMLButtonElement;
public circleButton: HTMLButtonElement;
public lineButton: HTMLButtonElement;
public exitControl: L.Control;
public dateFormat: string;
......@@ -137,11 +138,12 @@ module STWkit {
e.stopPropagation();
return false;
};
var initials = (options && options.initials) || '';
var showsingle = (options && options.singlebutton) || true;
var showmultiple = (options && options.multiplebutton) || false;
var showline = (options && options.linebutton) || true;
var showarea = (options && options.areabutton) || true;
var initials = (options && options.hasOwnProperty('initials'))?options.initials:'';
var showsingle = (options && options.hasOwnProperty('single'))?options.single:true;
var showmultiple = (options && options.hasOwnProperty('multiple'))?options.multiple:false;
var showpolygon = (options && options.hasOwnProperty('polygon'))?options.polygon: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 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>");
......@@ -158,17 +160,21 @@ module STWkit {
self.multipleButton.textContent = 'Multiple';
self.multipleButton.disabled = false;
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.textContent = 'Line';
self.lineButton.disabled = false;
if (!showline) self.lineButton.style.display = 'none';
self.polygonButton = <HTMLButtonElement>L.DomUtil.create('button', 'uk-button uk-button-small', objectButtonGroup);
self.polygonButton.textContent = 'Area';
if (!showarea) self.polygonButton.style.display = 'none';
self.polygonButton.textContent = 'Polygon';
if (!showpolygon) self.polygonButton.style.display = 'none';
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.multipleButton.onclick = function () { self.geometryType = "multipoint"; 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.hasPosition = false;
......@@ -245,6 +251,9 @@ module STWkit {
case 'point':
coordinates.push([latlngs[0][0].lng, latlngs[0][0].lat, 0]);
break;
case 'circle':
coordinates.push([latlngs[0][0].lng, latlngs[0][0].lat, 0]);
break;
case 'multipoint':
coordinates = geojson.features[0].geometry.coordinates;
for (var i = 0; i < coordinates.length; i++) {coordinates[i].push(0);}
......@@ -269,7 +278,7 @@ module STWkit {
}
});
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);
self.control.hideTable();
......@@ -356,17 +365,22 @@ module STWkit {
public defaults() {
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) {
var self = this;
var simulation = geojson.features[0].properties.simulation;
var type = geojson.features[0].geometry.type.toLowerCase();
if (geojson.features[0].properties.hasOwnProperty('radius')) type = 'circle';
switch (type) {
case "point":
self.pointButton.click();
break;
case "circle":
self.circleButton.click();
break;
case "multipoint":
self.multipleButton.click();
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