pull/3/head
Anthony Catel 2018-06-01 10:48:44 +02:00
commit 3192e8a2c7
3 zmienionych plików z 529 dodań i 0 usunięć

240
css/style.css 100644
Wyświetl plik

@ -0,0 +1,240 @@
#map {
height: 100%;
}
#mapcontainer {
width: 50%;
height: 100%;
float: left;
}
h1 {
font-size: 22px;
}
html, body {
height: 100%;
margin: 0;
padding: 0;
}
#main {
width: 50%;
height: 100%;
float: right;
padding: 0px 30px;
box-sizing: border-box;
font-family: Arial;
}
@media only screen and (max-width: 768px) {
#main {
width: 100%;
float: left;
height: 50%;
}
#mapcontainer {
width: 100%;
height: 50%;
float: left;
}
}
.dn {
display: none;
}
.desc {
padding: 10px;
border: 1px solid #bee0b1;
margin-bottom: 40px;
background-color: #dff0d8;
}
.bigger {
font-size: 25px;
}
#form .label {
display: block;
font-weight: bold;
}
#form .info {
width: 320px;
margin-bottom: 20px;
}
a {
color: #444;
}
.btn {
font-family: Arial;
color: #ffffff;
font-size: 18px;
background: #d42828;
padding: 8px 20px;
text-decoration: none;
display: inline-block;
}
.btn:hover {
background: #fc3c3c;
text-decoration: none;
}
.btnlarge {
font-family: Arial;
color: #ffffff;
font-size: 15px;
background: #37aacb;
padding: 5px 10px;
text-decoration: none;
display: block;
text-align: center;
margin-bottom: 4px;
border-radius: 4px;
}
.btnlarge:hover {
background: #249bbd;
text-decoration: none;
}
.exemples {
max-width: 350px;
margin-bottom: 25px;
font-size: 14px;
font-weight: bold;
}
input[type=range] {
-webkit-appearance: none;
width: 100%;
margin: 3.8px 0;
}
input[type=range]:focus {
outline: none;
}
input[type=range]::-webkit-slider-runnable-track {
width: 100%;
height: 8.4px;
cursor: pointer;
box-shadow: 1px 1px 1px #000000, 0px 0px 1px #0d0d0d;
background: #2c688e;
border-radius: 1.3px;
border: 0.2px solid #010101;
}
input[type=range]::-webkit-slider-thumb {
box-shadow: 0.1px 0.1px 1px #000000, 0px 0px 0.1px #0d0d0d;
border: 1px solid #000000;
height: 16px;
width: 16px;
border-radius: 5px;
background: #ffffff;
cursor: pointer;
-webkit-appearance: none;
margin-top: -4px;
}
input[type=range]:focus::-webkit-slider-runnable-track {
background: #3276a1;
}
input[type=range]::-moz-range-track {
width: 100%;
height: 8.4px;
cursor: pointer;
box-shadow: 1px 1px 1px #000000, 0px 0px 1px #0d0d0d;
background: #2c688e;
border-radius: 1.3px;
border: 0.2px solid #010101;
}
input[type=range]::-moz-range-thumb {
box-shadow: 0.1px 0.1px 1px #000000, 0px 0px 0.1px #0d0d0d;
border: 1px solid #000000;
height: 16px;
width: 16px;
border-radius: 5px;
background: #ffffff;
cursor: pointer;
}
input[type=range]::-ms-track {
width: 100%;
height: 8.4px;
cursor: pointer;
background: transparent;
border-color: transparent;
color: transparent;
}
input[type=range]::-ms-fill-lower {
background: #265a7b;
border: 0.2px solid #010101;
border-radius: 2.6px;
box-shadow: 1px 1px 1px #000000, 0px 0px 1px #0d0d0d;
}
input[type=range]::-ms-fill-upper {
background: #2c688e;
border: 0.2px solid #010101;
border-radius: 2.6px;
box-shadow: 1px 1px 1px #000000, 0px 0px 1px #0d0d0d;
}
input[type=range]::-ms-thumb {
box-shadow: 0.1px 0.1px 1px #000000, 0px 0px 0.1px #0d0d0d;
border: 1px solid #000000;
height: 16px;
width: 16px;
border-radius: 5px;
background: #ffffff;
cursor: pointer;
height: 8.4px;
}
input[type=range]:focus::-ms-fill-lower {
background: #2c688e;
}
input[type=range]:focus::-ms-fill-upper {
background: #3276a1;
}
.controls {
margin-top: 10px;
border: 1px solid transparent;
border-radius: 2px 0 0 2px;
box-sizing: border-box;
-moz-box-sizing: border-box;
height: 32px;
outline: none;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}
#pac-input {
background-color: #fff;
font-family: Roboto;
font-size: 15px;
font-weight: 300;
margin-left: 12px;
padding: 0 11px 0 13px;
text-overflow: ellipsis;
width: 300px;
}
#pac-input:focus {
border-color: #4d90fe;
}
.pac-container {
font-family: Roboto;
}
#type-selector {
color: #fff;
background-color: #4d90fe;
padding: 5px 11px 0px 11px;
}
#type-selector label {
font-family: Roboto;
font-size: 13px;
font-weight: 300;
}

71
index.html 100644
Wyświetl plik

@ -0,0 +1,71 @@
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<title>MapChecking - Vérificateur de densité urbaine</title>
<link rel="stylesheet" href="./css/style.css?3">
<meta name="author" content="Anthony Catel"/>
<meta property="og:type" content="website" />
<meta property="og:url" content="https://www.mapchecking.com/" />
<meta property="og:image" content="https://www.mapchecking.com/img/socialimage.png" />
<meta property="og:site_name" content="MapChecking" />
<meta property="og:description" content="MapChecking - Vérificateur de densité urbaine" />
<link rel="shortcut icon" type="image/ico" href="./img/favicon.ico"/>
</head>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.2.0/vue.min.js"></script>
<div id="mapcontainer">
<input id="pac-input" class="controls" type="text" placeholder="Search Box">
<div id="map"></div>
</div>
<div id="main">
<h1>Densité urbaine maximale - Fact checking</h1>
<div class="desc"><p>
<strong>Cet outil permet de vérifier le nombre maximal de personnes pouvant se situer dans une zone.</strong><br /><br />
Cliquez sur la carte pour ajouter des points et dessiner une zone.<br />
<strong>Copier l'adresse complète pour partager le résultat.</strong>
</p></div>
<div id="form">
<div class="info" v-bind:class="{ dn: isEmpty }">
<a id="resetzone" class="btn" href="javascript:void(0)">Effacer la zone</a>
</div>
<div class="label">Surface de la zone</div>
<div class="info">{{ surface }}m<sup>2</sup> <span v-if="surface == 0"><small>Dessinez d'abord une zone sur la carte</small></div>
<div class="label">Nombre de personnes par m<sup>2</sup></div>
<div class="label"><small><a href="http://www.gkstill.com/Support/crowd-density/625sm/Density6.html" target="_blank">Voir à quoi cela correspond</a></small></div>
<div class="info"><input v-model="density" id="density" type="range" step="0.1" min="0.1" v-bind:max="maxdensity" />{{ density }} personne{{ density | pluralize }} par m<sup>2</sup></div>
<div class="label">Nombre maximum de personnes</div>
<div class="info bigger">{{ maxpersonne }} <span v-if="surface == 0"><small>Dessinez d'abord une zone sur la carte</small></span></div>
<hr />
<div class="exemples">
Exemples :<br />
<a class="btnlarge" href="https://goo.gl/dzyP85">Place du Trocadero</a>
<a class="btnlarge" href="https://goo.gl/nvlodI">Place de la République</a>
</div>
<div>
<span>Outil réalisé par Anthony Catel</span>
<a href="https://twitter.com/paraboul" class="twitter-follow-button" data-show-count="true">Follow @paraboul</a><script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script><br />
<span style="font-size: 10px;">MapChecking n'est affilié à aucun parti ou institution.</span>
</div>
</div>
</div>
<script src="./js/main.js?4"></script>
<script async defer src="https://maps.googleapis.com/maps/api/js?key=AIzaSyD7Vm3gm4Fm7jSkuIh_yM14GmYhz1P_S4M&libraries=geometry,places&callback=initMap"></script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-93201926-1', 'auto');
ga('send', 'pageview');
</script>
</body>
</html>

218
js/main.js 100644
Wyświetl plik

@ -0,0 +1,218 @@
// Anthony Catel - paraboul@gmail.com - twitter.com/paraboul/
var updateHashTimer = null;
var vue = new Vue({
el: "#form",
data: {
surface: 0,
density: 1,
maxdensity: 7,
isEmpty: true,
arrPoly: [],
mapPosition: [48.862895, 2.286978, 18]
},
computed: {
maxpersonne: function() {
return parseInt(this.surface * this.density)
},
hash: function() {
var fin = [];
for (var i = 0; i < this.arrPoly.length; i++) {
var el = this.arrPoly[i];
fin.push(el.lat().toFixed(7) + ',' + el.lng().toFixed(7));
}
fin.push(this.density);
fin.push(this.mapPosition.join(','));
return fin.join(';')
},
},
watch: {
hash: function(hashval) {
if (updateHashTimer) {
clearTimeout(updateHashTimer);
}
updateHashTimer = setTimeout(function() {
window.location.hash = hashval;
}, 300);
},
density: function(newval) {
mc.densityChanged();
}
},
filters: {
pluralize: function(src) {
if (src > 1) return 's';
return '';
}
}
});
var mc = null;
var MapCheck = function() {
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 18,
center: {lat: 48.862895, lng: 2.286978},
mapTypeId: 'roadmap'
});
this.map = map;
var input = document.getElementById('pac-input');
var searchBox = new google.maps.places.SearchBox(input);
map.controls[google.maps.ControlPosition.TOP_LEFT].push(input);
// Bias the SearchBox results towards current map's viewport.
map.addListener('bounds_changed', function() {
searchBox.setBounds(map.getBounds());
});
searchBox.addListener('places_changed', function() {
var places = searchBox.getPlaces();
console.log("Places", places.length);
if (places.length == 0) {
return;
}
var place = places[0];
map.setCenter(place.geometry.location);
map.setZoom(17);
});
this.poly = new google.maps.Polygon({
strokeColor: '#FF0000',
strokeOpacity: 0.8,
strokeWeight: 2,
fillColor: '#FF0000',
fillOpacity: 0.35,
editable: true,
draggable: true,
geodesic: true
});
this.poly.setMap(map);
function mapUpdate() {
var pos = map.getCenter();
var zoom = map.getZoom();
vue.mapPosition = [pos.lat().toFixed(7), pos.lng().toFixed(7), zoom];
}
map.addListener('center_changed', mapUpdate);
map.addListener('zoom_changed', mapUpdate);
map.addListener('click', addLatLng.bind(this));
map.setOptions({
draggableCursor:'crosshair',
clickableIcons: false,
disableDoubleClickZoom: true
});
function addLatLng(event) {
var path = this.poly.getPath();
path.push(event.latLng);
vue.isEmpty = false;
this.updateSurface();
}
this.setPolyEvents();
}
MapCheck.prototype.setPosition = function(lat, lng, zoom) {
this.map.setCenter({lat: parseFloat(lat), lng: parseFloat(lng)});
this.map.setZoom(parseInt(zoom));
}
MapCheck.prototype.setPolyColor = function(r, g, b) {
this.poly.setOptions({
fillColor: 'rgb('+r+', '+g+', '+b+')',
strokeColor: 'rgb('+r+', '+g+', '+b+')'
})
}
MapCheck.prototype.updateSurface = function() {
vue.surface = google.maps.geometry.spherical.computeArea(this.poly.getPath()).toFixed(2);
vue.arrPoly = this.poly.getPath().getArray().slice();
return true;
}
MapCheck.prototype.reset = function() {
this.poly.getPath().clear();
vue.isEmpty = true;
}
MapCheck.prototype.setPolyEvents = function() {
google.maps.event.addListener(this.poly.getPath(), "insert_at", this.updateSurface.bind(this));
google.maps.event.addListener(this.poly.getPath(), "remove_at", this.updateSurface.bind(this));
google.maps.event.addListener(this.poly.getPath(), "set_at", this.updateSurface.bind(this));
}
MapCheck.prototype.densityChanged = function() {
var r = parseInt(255 * (vue.density / 1));
var g = 255 - parseInt(255 * (vue.density / 4));
this.setPolyColor(r, g, 0);
}
function initMap() {
mc = new MapCheck();
document.getElementById("resetzone").addEventListener("click", function() {
mc.reset();
});
var pageHash = window.location.hash;
if (pageHash && pageHash.length > 3) {
pageHash = pageHash.substring(1);
var opt = pageHash.split(';');
var curPosition = opt.pop();
if (curPosition) {
var cursetting = curPosition.split(',');
mc.setPosition(cursetting[0], cursetting[1], cursetting[2]);
}
vue.density = parseFloat(opt.pop()) || 1;
var path = [];
for (var i = 0; i < opt.length; i++) {
var coord = opt[i].split(',');
path.push({
lat: parseFloat(coord[0]),
lng: parseFloat(coord[1])
});
}
if (path.length) {
vue.isEmpty = false;
mc.poly.setPath(path);
mc.setPolyEvents();
}
mc.updateSurface();
}
mc.densityChanged();
}