/** * Javascript pour construire la carte. * Utilise: * - Leaflet * - Leaflet.markercluster */ var dataFiles = { assosLayer: '/geo_data/associations_geojson?do=export_text', epnsLayer: '/geo_data/associations_geojson?datafilter=epn&do=export_text', adminLayer: '/_media/geo_data/agglo_tours_admin.geo.json', cucsLayer : '/_media/geo_data/cucs_wgs84.geo.json' , irisLayer: '/_media/geo_data/agglo_tours_iris2.geo.json', qppv2015: '/geo_data/quartiers-prioritaires-2015_wgs84_geojson?do=export_raw' //epnsLayer: '/_media/geo_data/espace-public-numerique-epn_37.geocode.geo.json' }; function mapInit() { var viewCenter = [ 47.3903853, 0.6899713 ]; // Tours admin_centre var assosLayerGeoJson = L.geoJson(null, { onEachFeature : assos_onEachFeature }); var assosLayer = L.markerClusterGroup(); jQuery.getJSON( dataFiles.assosLayer, function( data) { assosLayerGeoJson.addData(data); assosLayer.addLayer(assosLayerGeoJson); }); var adminLayer = L.geoJson(null, { 'style' : admin_style, pointToLayer: function (feature, latlng) { return L.marker(latlng, {icon: new AdminIcon()}) ; } }); jQuery.getJSON( dataFiles.adminLayer, function( data) { adminLayer.addData(data); }); var cucsLayer = L.geoJson(null, { onEachFeature : cucs_onEachFeature, 'style' : cucs_style }); jQuery.getJSON( dataFiles.cucsLayer, function( data) { cucsLayer.addData(data); }); var irisLayer = L.geoJson(null, { 'style' : iris_style }); jQuery.getJSON( dataFiles.irisLayer, function( data) { irisLayer.addData(data); }); var epnsLayer = L.geoJson( null, { pointToLayer: function (feature, latlng) { return L.marker(latlng, {icon: new EpnIcon()}) ; }, onEachFeature : epns_onEachFeature }); jQuery.getJSON( dataFiles.epnsLayer, function( data) { epnsLayer.addData(data); }); var qppvLayer = L.geoJson(null, { //onEachFeature : cucs_onEachFeature, style : qppv_style }); jQuery.getJSON( dataFiles.qppv2015 ) .done( function( data) { qppvLayer.addData(data); }); var overlayMaps = { "Insee iris" : irisLayer , "Admin" : adminLayer, "CUCS 2014" : cucsLayer , "QPPV 2015" : qppvLayer , "Assos" : assosLayer, 'EPNs assos ' : epnsLayer } var tilesOsmFr = L .tileLayer( 'http://{s}.tile.openstreetmap.fr/osmfr/{z}/{x}/{y}.png', { attribution : 'Map data © OpenStreetMap contributors, Imagery © OpenStreetMap.FR', maxZoom : 20 }); var tilesOpenMapquest = L .tileLayer( 'http://otile1.mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.jpg', { attribution : 'Tuiles de fond © MapQuest ', description : 'Tuiles OpenMapQuest', maxZoom : 19 }); var tilesMaps = { "OsmFR" : tilesOsmFr, "OpenMapquest" : tilesOpenMapquest }; map = L.map('map', { layers : [ tilesOsmFr, assosLayer ] }).setView(viewCenter, 12); L.control.layers( tilesMaps, overlayMaps,{collapsed:false}).addTo(map); //map.fitBounds(assosLayer.getBounds()); // error: TypeError: this._northEast is undefined info = L.control(); info.onAdd = function( map) { this._div = L.DomUtil.create('div', 'info'); this.update(); return this._div; }; info.update = function( props) { this._div.innerHTML = (props ? '
' + props.text + '
' : 'Afficher les infos sur un point
'); }; info.addTo(map); } function assos_onEachFeature( feature, layer) { if( feature.properties /* && feature.properties.popupContent */) { var p=feature.properties; layer.bindPopup('' + p.address
+ '
'+p.web+''
+ '
' + 'CUCS' + (feature.properties.ZUS == 1 ? ' + ZUS' : '') + '
'); layer.on({ mouseover : cucs_mouse_update_info, mouseout : cucs_mouse_update_info, click : cucs_mouse_update_info }); } } function cucs_mouse_update_info( e) { if( e.type == "mouseout" ) { info.update(); return; } var props = e.target.feature.properties; info.update({ 'title' : props.name, 'text' : 'CUCS' + (props.ZUS == 1 ? ' + ZUS' : '') }); } function epns_onEachFeature( feature, layer) { if( feature.properties /* && feature.properties.popupContent */) { var p=feature.properties; layer.bindPopup('' + p.address
+ '
'+p.web+''
+ '