« Widget:CartoFab » : différence entre les versions

De fablabo
Aller à :navigation, rechercher
Cedric (discussion | contributions)
Aucun résumé des modifications
Cedric (discussion | contributions)
Aucun résumé des modifications
Ligne 83 : Ligne 83 :
<script>
<script>


///fonction pour recuperer la liste des coords des labs
function requete(url) {
if (window.XMLHttpRequest)  // Mozilla, Safari,...
  xhr = new XMLHttpRequest();
else if (window.ActiveXObject)
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
if (!xhr) {
  alert("Abandon : Impossible de créer une instance Ajax");
  return false;
}
xhr.onreadystatechange = reponse;
xhr.open("GET", url, true);
xhr.send(null);
}


function reponse() {
if (xhr.readyState == 4) {
if (xhr.status == 200) {
//alert(xhr.responseText);
//le fichier arrive en CSV (valeurs séparées par des virgules)
var lignes=new RegExp("[\n]+", "g");
//alert(responseText);
var tableau=xhr.responseText.split(lignes);
var colones=new RegExp("[,]+", "g");
for(var i=1;i<tableau.length-1;i++)
{
var donnees=tableau[i].split(colones);
  var coords=new Array(donnees[2],donnees[1]);
  var nom=donnees[0];
  var url=donnees[3];
  var intitule=donnees[5];//type de lieu
  var structure=donnees[6];//structure juridique
  // alert(coords[0]);
  L.marker([coords[0], coords[1]]).addTo(cartofab).bindPopup("<b><a href="+url+" target=\"_blank\">"+nom+"</a></b><br/>"+intitule+"<br/>"+structure);
}
document.getElementById("nombreLabos").innerHTML = "Il ya actuellement "+tableau.length+" laboratoires renseignés sur cette page";
document.getElementById("nombreLabos").innerHTML =responseText;
}
else {
    alert("La requête AJAX a rencontré un problème ..");
  }
}
}




Ligne 155 : Ligne 106 :


//appel de la liste des labs
//appel de la liste des labs
requete("Sp%C3%A9cial:Ask/-5B-5BCategory:Fablabs-5D-5D/-3FLong-23-2D/-3FLatt-23-2D/-3FSite/-3FAdresse/-3FIntitul%C3%A9/-3FStructures/limit%3D50/format%3Djson/sep%3D,/headers%3Dshow");
//requete("Sp%C3%A9cial:Ask/-5B-5BCategory:Fablabs-5D-5D/-3FLong-23-2D/-3FLatt-23-2D/-3FSite/-3FAdresse/-3FIntitul%C3%A9/-3FStructures/limit%3D50/format%3Djson/sep%3D,/headers%3Dshow");




Ligne 164 : Ligne 115 :
   function(data) {
   function(data) {
     $.each(data.items, function(i,item){
     $.each(data.items, function(i,item){
      alert(i+"="+item.label);
    // alert(i+"="+item.label);
      L.marker([item.long, item.latt]).addTo(cartofab).bindPopup("<b><a href="+item.site+" target=\"_blank\">"+item.label+"</a></b><br/>"+intitule+"<br/>"+structure);
      document.getElementById("nombreLabos").innerHTML = "Il ya actuellement "+tableau.length+" laboratoires renseignés sur cette page";
 
 
     });
     });
   });
   });


</script>
</script>

Version du 6 novembre 2012 à 16:46

Proto de développement dewidget:CarteFablabs


usage : {{#widget:CartoFab |nom=(optionnel) |longitude=51(optionnel) |latitude=3.56(optionnel) |zoom=1 a 18(optionnel) |largeur=(optionnel) |hauteur=(optionnel) }}

trouver les coordonnées : http://universimmedia.pagesperso-orange.fr/geo/nievre.htm

on peut utiliser un droplet présent sur cette page pour connaitre les coords d'un objet :http://www.mediawikiwidgets.org/Google_Maps


inspiration: http://www.mediawikiwidgets.org/w/index.php?title=Widget:Google_Maps&action=edit

item nom artlab

adresse 11ème Paris site http://www.digitalarti.com/fr/blog/artlab_blog long 2.3 latt 48.8 intitulé fablab structures sarl


ne pas effacer ! ça sert ! JSON

cartographie tous les fablabs



L.marker([51.5, -0.09]).addTo(map) .bindPopup("Hello world!
I am a popup.").openPopup();




<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.4.4/leaflet.css" />

<script src="http://cdn.leafletjs.com/leaflet-0.4/leaflet.js"></script>

csv

<script>




///////////fin javaload


var cartofab = L.map().setView([, ], );

L.tileLayer('http://{s}.tile.cloudmade.com/7ad1b23bf3f347f8b0ab2416f66737fc/997/256/{z}/{x}/{y}.png', { maxZoom: 18, attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="http://cloudmade.com">CloudMade</a>' }).addTo(cartofab);




//appel de la liste des labs //requete("Sp%C3%A9cial:Ask/-5B-5BCategory:Fablabs-5D-5D/-3FLong-23-2D/-3FLatt-23-2D/-3FSite/-3FAdresse/-3FIntitul%C3%A9/-3FStructures/limit%3D50/format%3Djson/sep%3D,/headers%3Dshow");



$.getJSON("Sp%C3%A9cial:Ask/-5B-5BCategory:Fablabs-5D-5D/-3FLong-23-2D/-3FLatt-23-2D/-3FSite/-3FAdresse/-3FIntitul%C3%A9/-3FStructures/limit%3D50/searchlabel%3D/format%3Djson",

 function(data) {
   $.each(data.items, function(i,item){
    // alert(i+"="+item.label);
     L.marker([item.long, item.latt]).addTo(cartofab).bindPopup("<a href="+item.site+" target=\"_blank\">"+item.label+"</a>
"+intitule+"
"+structure); document.getElementById("nombreLabos").innerHTML = "Il ya actuellement "+tableau.length+" laboratoires renseignés sur cette page";


   });
 });

</script>