Skip to content

Instantly share code, notes, and snippets.

View AdrienVH's full-sized avatar

Adrien VAN HAMME AdrienVH

View GitHub Profile
@AdrienVH
AdrienVH / calcul_rayon_cercles_proportionnels.js
Last active April 21, 2016 16:33
Calculer le rayon de cercles proportionnels (en fixant un diamètre minimal ou maximal)
/*
Méthodologie : http://blog.adrienvh.fr/2014/04/09/calculer-le-rayon-de-cercles-proportionnels/
*/
// Distribution statistique
var distribution = [25, 46, 2, 39, 30, 21, 3, 19, 15, 5]; // http://www.random.org/integer-sets/
var valeur_min = Math.min.apply(Math, distribution);
var valeur_max = Math.max.apply(Math, distribution);
// Calcul du rayon (diamètre minimal fixé)
@AdrienVH
AdrienVH / itineraire_gmaps_openlayers.js
Last active August 22, 2017 10:46
Utiliser Google Maps pour calculer un itinéraire entre deux adresses, et l'afficher dans une carte OpenLayers
/*
Pré-requis : charger la librairie Google Maps, son module Geometry, et la librairie OpenLayers :
<script src="https://maps.googleapis.com/maps/api/js?key=...&libraries=geometry&sensor=false"></script>
<script src="http://openlayers.org/api/OpenLayers.js"></script>
*/
// Carte
var cartographie = new OpenLayers.Map('carte'); // <div id="carte"></div>
var couche_osm = new OpenLayers.Layer.OSM('OSM');
cartographie.addLayer(couche_osm);
@AdrienVH
AdrienVH / itineraire_gmaps.js
Last active April 21, 2016 16:34
Utiliser Google Maps pour calculer un itinéraire entre deux adresses
/*
Pré-requis : charger la librairie Google Maps :
<script src="https://maps.googleapis.com/maps/api/js?key=...&sensor=false"></script>
*/
// Adresses
var origin = '191 rue Saint-Jacques, Paris';
var destination = '37 bd Romain Rolland, Montrouge';
// Itinéraire
@AdrienVH
AdrienVH / itineraire_gmaps.php
Last active April 23, 2021 19:50
Appeler Google Maps pour calculer un itinéraire entre deux adresses
<?php
$url = 'http://maps.googleapis.com/maps/api/directions/json?';
// Adresses
$origin = '191 rue Saint-Jacques, Paris';
$destination = '37 bd Romain Rolland, Montrouge';
// Itinéraire
$params = http_build_query(array('origin' => $origin, 'destination' => $destination, 'sensor' => 'false'));
$appel_api = file_get_contents($url.$params);
@AdrienVH
AdrienVH / geocodage_nominatim.php
Last active August 29, 2015 14:00
Appeler Nominatim (OSM) pour géocoder une ou plusieurs adresses
<?php
$url = 'http://nominatim.openstreetmap.org/search?';
// Adresses
$adresses[] = '191 rue Saint-Jacques, Paris';
$adresses[] = 'Parc des Buttes Chaumont, Paris';
$adresses[] = '37 bd Romain Rolland, Montrouge';
// Géocodage
foreach($adresses as $adresse)