Commit 85deec89 authored by hichbra's avatar hichbra

Ajout du visu GPS

parent 5d249590
......@@ -74,7 +74,6 @@
</div>
</div>
<div class="wrapper wrapper-content animated fadeInRight graphique">
<div class="row">
<div class="col-lg-12">
......@@ -89,3 +88,9 @@
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<div id="mapdiv" style="height:500px; display:none;"></div>
</div>
</div>
<script src="http://www.openlayers.org/api/OpenLayers.js"></script>
<script>
var map = null, mappingLayer, vectorLayer, selectMarkerControl, selectedFeature;
var table ;
function valeurPresentes() {
......@@ -176,7 +179,6 @@ function majChart(idCapteur, debut, fin, limite=500) {
var valeurs = [0, 0];
var labels = [0, 0];
}
console.log(labels);
if($("#displayTab").prop("checked")) {
$("#tableauDiv").css("block");
......@@ -201,7 +203,10 @@ function majChart(idCapteur, debut, fin, limite=500) {
}
if($.isNumeric(valeurs[0])){
/** CAPTEUR DE VALEUR **/
$(".graphique").css("display", "");
$("#mapdiv").css("display", "none");
var interpolationX = $("#interpolationX").val();
if(!$.isNumeric(interpolationX)){
......@@ -218,13 +223,29 @@ function majChart(idCapteur, debut, fin, limite=500) {
labels: labels
}, getOptionsChart(interpolationX));
} else {
$(".graphique").css("display", "none");
}
},
failure : function(response){
}
else {
/** GPS **/
$("#mapdiv").css("display", "");
$(".graphique").css("display", "none");
initMap();
for (var val in valeurs) {
value = valeurs[val].trim();
var temps = parse.table[val].temps ;
var lat = value.split(",")[0];
var lon = value.split(",")[1];
if (lat != "-999" && lon != "-999"){
placeMarker(lat, lon, temps);
}
}
}
},
failure : function(response){
alert("Error! Please Contact technical support");
}
}
});
}
......@@ -258,6 +279,86 @@ function initButtonSwitch() {
var init = new Switchery(elem);
}
function onFeatureSelect(feature) {
selectedFeature = feature;
popup = new OpenLayers.Popup.FramedCloud("tempId", feature.geometry.getBounds().getCenterLonLat(),
null,
selectedFeature.attributes.salutation + " from Lat:" + selectedFeature.attributes.Lat + " Lon:" + selectedFeature.attributes.Lon,
null, true);
feature.popup = popup;
map.addPopup(popup);
}
function onFeatureUnselect(feature) {
map.removePopup(feature.popup);
feature.popup.destroy();
feature.popup = null;
}
function initMap(){
if (map != null){
map.destroy();
}
map = new OpenLayers.Map('mapdiv');
mappingLayer = new OpenLayers.Layer.OSM("Simple OSM Map");
map.addLayer(mappingLayer);
vectorLayer = new OpenLayers.Layer.Vector("Vector Layer", {projection: "EPSG:4326"});
selectMarkerControl = new OpenLayers.Control.SelectFeature(vectorLayer, {onSelect: onFeatureSelect, onUnselect: onFeatureUnselect});
map.addControl(selectMarkerControl);
selectMarkerControl.activate();
map.addLayer(vectorLayer);
map.setCenter(
new OpenLayers.LonLat(0, 0).transform(
new OpenLayers.Projection("EPSG:4326"),
map.getProjectionObject())
, 13
);
}
function placeMarker(lat, lon, temps){
var latitude = lat;
var longitude = lon;
var date = new Date(temps);
var options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' };
var lonLat = new OpenLayers.Geometry.Point(longitude, latitude);
lonLat.transform("EPSG:4326", map.getProjectionObject());
var feature = new OpenLayers.Feature.Vector(
lonLat,
{ Lon : longitude, Lat : latitude},
{ label : temps});
vectorLayer.addFeatures(feature);
/*
var date = new Date(temps);
var options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' };
var popup = new OpenLayers.Popup.FramedCloud("tempId", new OpenLayers.LonLat( longitude, latitude).transform("EPSG:4326", map.getProjectionObject()),
null,
"<dl><dt>"+date.toLocaleDateString('fr-FR', options)+" "+date.toLocaleTimeString('fr-FR') + "</dt><dd>Lat:" + feature.attributes.Lat + " Lon:" + feature.attributes.Lon+"</dd></dl>",
null, true);
feature.popup = popup;
map.addPopup(popup);*/
lonLat = new OpenLayers.LonLat( lon, lat )
.transform(
new OpenLayers.Projection("EPSG:4326"), // transform from WGS 1984
map.getProjectionObject() // to Spherical Mercator Projection
);
var zoom=10;
var markers = new OpenLayers.Layer.Markers( "Markers" );
map.addLayer(markers);
markers.addMarker(new OpenLayers.Marker(lonLat));
map.setCenter(lonLat, zoom);
}
$(document).ready(function(){
initButtonSwitch();
......
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