1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186
|
Ext.apply(Ext.form.VTypes, {
daterange : function(val, field) {
var date = field.parseDate(val);
if(!date){
return;
}
if (field.startDateField && (!this.dateRangeMax || (date.getTime() != this.dateRangeMax.getTime()))) {
var start = Ext.getCmp(field.startDateField);
start.setMaxValue(date);
start.validate();
this.dateRangeMax = date;
}
else if (field.endDateField && (!this.dateRangeMin || (date.getTime() != this.dateRangeMin.getTime()))) {
var end = Ext.getCmp(field.endDateField);
end.setMinValue(date);
end.validate();
this.dateRangeMin = date;
}
/*
* Always return true since we're only using this vtype to set the
* min/max allowed values (these are tested for after the vtype test)
*/
return true;
}
});
// Parmètres d'affichage de la carte
// var lon=2
// var lat=47
// var zoom=5
// Une fois le chargement effectué...
Ext.onReady(function() {
// ----------------------------- OpenLayers -----------------------------------------------
OpenLayers.Lang.code="fr";
// Nouvel objet Map
var map = new OpenLayers.Map( 'map', optionsMap );
// Options de la carte
var optionsMap = {
projection: new OpenLayers.Projection("EPSG:900913"),
displayProjection: new OpenLayers.Projection("EPSG:4326"),
units: "m",
};
// Couche Google Physical
var gphy = new OpenLayers.Layer.Google(
"Google Physical",
{type: G_PHYSICAL_MAP}
);
// Couche Google Hybrid
var ghyb = new OpenLayers.Layer.Google(
"Google Hybrid",
{type: G_HYBRID_MAP}
);
// Couche Google Satellite
var gsat = new OpenLayers.Layer.Google(
"Google Satellite",
{type: G_SATELLITE_MAP}
);
// Couche Google Street
var gmap = new OpenLayers.Layer.Google(
"Google Streets",
{type: G_NORMAL_MAP}
);
// Creation d'une couche vecteur
var vecLayer = new OpenLayers.Layer.Vector("vector",
{
projection: new OpenLayers.Projection("EPSG:4326"),
displayProjection: new OpenLayers.Projection("EPSG:4326")
}
);
// Ajout des couches raster à la carte
map.addLayers([gsat, gphy, ghyb, gmap, vecLayer]);
// -------------------------------------------------------------------------------------------
// Nouvel objet Panel
var panel = new OpenLayers.Control.Panel({defaultControl: pan});
// Nouveau control Pan
var pan = new OpenLayers.Control.MouseDefaults({title:"Déplacement"});
// Historique de navigation
nav = new OpenLayers.Control.NavigationHistory();
map.addControl(nav);
// Gestionnaire de couches
map.addControl(new OpenLayers.Control.LayerSwitcher());
// Le cadre acceuillant les differents controls
panel.addControls([
pan,
new OpenLayers.Control.ZoomBox({title:"Zoom +"}),
nav.next,nav.previous,
new OpenLayers.Control.ScaleLine(),
new OpenLayers.Control.Permalink('permalink'),
new OpenLayers.Control.MousePosition(),
new OpenLayers.Control.Navigation(),
]);
// Ajout des controls à la carte
map.addControl(panel);
// --------------------- GeoExt --------------------------------------------------------
var mapUI = new GeoExt.MapPanel({
region : 'center',
title: 'A Simple GeoExt Map',
center: new OpenLayers.LonLat(2, 47),
zoom: 5,
map: map
});
// Creation du bloc de données pour la "grid"
var store = new GeoExt.data.FeatureStore({
layer: vecLayer,
fields: [
{name: 'code_capta', type: 'integer'},
{name: 'Departemen', type: 'integer'},
{name: 'Molecule', type: 'string'},
{name: 'Commune', type: 'string'},
{name: 'Point_X', type: 'integer'},
{name: 'Point_Y', type: 'integer'}
],
proxy: new GeoExt.data.ProtocolProxy({
protocol: new OpenLayers.Protocol.HTTP({
url: "http://manu.thiebaut4.free.fr/data/captage_wgs84.gml",
format: new OpenLayers.Format.GML(),
})
}),
autoLoad: true
});
// Création de la "grid" configurée à partir du "store"
var gridPanel = new Ext.grid.GridPanel({
store: store,
region: 'east',
title: 'Observations',
width: '30%',
split: true,
columns: [{
header: "Code",
dataIndex: "code_capta",
sortable:true
}, {
header: "Département",
dataIndex: "Departemen",
sortable:true
}, {
header: "Molécule Active",
dataIndex: "Molecule",
sortable:true
}, {
header: "Commune",
dataIndex: "Commune",
sortable:true
}, {
header: "Coordonnée X",
dataIndex: "Point_X",
sortable:true
}, {
header: "Coordonnée Y",
dataIndex: "Point_Y",
sortable:true
}],
sm: new GeoExt.grid.FeatureSelectionModel()
});
// Viewport
new Ext.Viewport({
layout: "border",
items: [mapUI, gridPanel]
});
}); |
Partager