Commit be7c95c3 authored by Richard's avatar Richard

worked on flood browser, dikes polygons are showing

parent c2aef539
...@@ -6,8 +6,8 @@ Ext.Loader.setPath({ ...@@ -6,8 +6,8 @@ Ext.Loader.setPath({
Ext.application({ Ext.application({
controllers: ["Main"], controllers: ["Main"],
models: ["SimulationModel", 'SimulationDetails'], models: ["SimulationModel", "SimulationDetails"],
stores: ['SimulationStore', 'ImagesStore'], stores: ['SimulationStore', 'SimulationDetailsStore'],
name: 'app', name: 'app',
......
...@@ -20,21 +20,48 @@ Ext.define('app.controller.Main', { ...@@ -20,21 +20,48 @@ Ext.define('app.controller.Main', {
setMap: function(extmap, map){ setMap: function(extmap, map){
this.globalMap = map; this.globalMap = map;
this.getMapView().setGlobalMap(extmap, map); this.getMapView().setGlobalMap(extmap, map);
var traffic = new google.maps.TrafficLayer(); // var traffic = new google.maps.TrafficLayer();
traffic.setMap(map); // traffic.setMap(map);
}, },
showOverlay: function(list, index, element, record) { showOverlay: function(list, index, element, record) {
var store = Ext.getStore('ImagesStore'); //var area_id = record.get('area_id');
store.setUrl(record.get('area_id')); var store = Ext.getStore('SimulationDetailsStore');
store.load(); var area_id = record.get('area_id');
var map = this.getMapView();
var dikes = null;
//store.setUrl(record.get('area_id'));
//console.log(store.getData().getCount());
//console.log(store.getData().getAt(0).get('dikes'));
//var dikes = store.getData().getAt(0).get('dikes');
var bounds = record.get('visbounds'); var bounds = record.get('visbounds');
var center = record.get('center'); var center = record.get('center');
var corners = record.get('corners'); var corners = record.get('corners');
var request = Ext.Ajax.request({
method: 'GET',
url: 'http://sangkil.science.uva.nl:8003/area/' + area_id + '/info.json',
success: function(response, opts){
console.log(response);
var result = Ext.decode(response.responseText);
console.log(this);
if (result['dikes'].length > 0)
map.createOverlayPolygon(result['dikes']);
},
});
//var result = Ext.decode(request.responseText);
// console.log(result);
//if (result['dikes'].length > 0)
// this.getMapView().createOverlayPolygon(result['dikes']);
this.getMapView().createMarker();
//this.getMapView().createOverlayImage(bounds);
this.getMapView().setCenterMap(center); this.getMapView().setCenterMap(center);
this.getMapView().createOverlayImage(bounds);
this.getMapView().createOverlayPolygon(corners);
}, },
callMapPolygon: function(polygon)
{
this.getMapView().createOverlayPolygon(polygon);
}
}); });
\ No newline at end of file
Ext.define('app.store.ImagesStore', { Ext.define('app.store.SimulationDetailsStore', {
extend: 'Ext.data.Store', extend: 'Ext.data.Store',
requires: ['Ext.data.proxy.Rest'], requires: ['Ext.data.proxy.Rest'],
xtype: 'ImagesStore', xtype: 'SimulationDetailsStore',
config : { config: {
model: 'app.model.SimulationDetails', model: 'app.model.SimulationDetails',
fields: ['name', 'corners', 'visbounds', 'area_id', 'center'], fields: ['name', 'center', 'corners', 'size', 'extents', 'visbounds', 'vissize', 'projection', 'dikes'],
proxy : { proxy: {
type: 'rest', type: 'rest',
url: 'http://sangkil.science.uva.nl:8003/area/', url: 'http://sangkil.science.uva.nl:8003/area/',
reader: { reader: {
type: 'json', type: 'json',
}, },
callback: function(response) {
console.log(response.responseText);
}
},
listeners: {
beforeload: function(store){
console.log(store);
}
} }
}, },
setUrl: function(area_id) { setUrl: function(area_id) {
var store = Ext.getStore('ImagesStore').getProxy(); var store = Ext.getStore('SimulationDetailsStore').getProxy();
store._url = 'http://sangkil.science.uva.nl:8003/area/' + area_id + '/info.json'; store._url = 'http://sangkil.science.uva.nl:8003/area/' + area_id + '/info.json';
} }
}); });
\ No newline at end of file
...@@ -11,7 +11,7 @@ Ext.define("app.view.List", ...@@ -11,7 +11,7 @@ Ext.define("app.view.List",
'Ext.data.Store', 'Ext.dataview.List', 'Ext.Map' 'Ext.data.Store', 'Ext.dataview.List', 'Ext.Map'
], ],
stores: ['SimulationStore'], //stores: ['SimulationStore'],
config: { config: {
layout: "vbox", layout: "vbox",
......
...@@ -30,8 +30,8 @@ Ext.define('app.view.Map', { ...@@ -30,8 +30,8 @@ Ext.define('app.view.Map', {
this.globalExtMap.setMapOptions(options); this.globalExtMap.setMapOptions(options);
}, },
createMarker: function(position){ createMarker: function(pos){
var pos = new google.maps.LatLng(52.3700,4.89000); var pos = new google.maps.LatLng(52.3700, 4.89000);
new google.maps.Marker({ new google.maps.Marker({
position: pos, position: pos,
icon: 'Google_Maps_Marker.png', icon: 'Google_Maps_Marker.png',
...@@ -51,14 +51,14 @@ Ext.define('app.view.Map', { ...@@ -51,14 +51,14 @@ Ext.define('app.view.Map', {
createOverlayPolygon: function(corners){ createOverlayPolygon: function(corners){
var cornerBounds = []; var cornerBounds = [];
for (i in corners) { console.log(corners);
console.log(corners[i][0], corners[i][1]); console.log(corners[0].length);
cornerBounds.push(new google.maps.LatLng(corners[i][0], corners[i][1])); for (var i = 0; i < corners[0].length - 1; i++) {
}
new google.maps.LatLng(corners[1][0],corners[1][1]), console.log("i: " + i + corners[0][i][0] + "-" + corners[0][i][1]);
new google.maps.LatLng(corners[2][0],corners[2][1]), cornerBounds.push(new google.maps.LatLng(corners[0][i][0], corners[0][i][1]));
new google.maps.LatLng(corners[3][0],corners[3][1]) }
console.log(cornerBounds);
var rectangle = new google.maps.Polygon({ var rectangle = new google.maps.Polygon({
paths: cornerBounds, paths: cornerBounds,
......
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