0) :
$js = '';
$GLOBALS['wiki']->AddJavascriptFile('tools/contact/libs/contact.js');
$GLOBALS['wiki']->AddCSSFile('tools/bazar/libs/vendor/leaflet/leaflet.css');
$GLOBALS['wiki']->AddCSSFile('tools/bazar/libs/vendor/leaflet/leaflet.ie.css', '');
$GLOBALS['wiki']->AddCSS('
/* taille de la popup en fonction de la resolution */
.modal-dialog {
position: relative;
width: auto;
margin: 5px;
}
@media (min-width: 768px) {
.modal-dialog {
width: 700px;
margin: 30px auto;
}
}
@media (min-width: 992px) {
.modal-lg {
width: 1000px;
}
}
/* ajustements pour les facettes */
.filters .panel-heading {
border: none;
text-transform: uppercase;
padding: 4px 8px;
}
.filters .panel-default {
margin-bottom: 15px;
}
.titre-popup {
font-size:23px;
}
.leaflet-popup-content p {
margin: 0 0 2px 0;
}
.leaflet-popup-content .popup-content {
/* height:200px;*/
overflow-y : auto;
}
.leaflet-popup-content .btn-primary { color:#fff; }
.leaflet-popup-content img {
max-width: 100% !important;
}
');
$GLOBALS['wiki']->AddJavascriptFile('tools/bazar/libs/bazar.js');
$GLOBALS['wiki']->AddJavascriptFile('tools/bazar/libs/vendor/leaflet/leaflet.js');
$GLOBALS['wiki']->AddJavascriptFile('tools/bazar/libs/vendor/leaflet/leaflet-providers.js');
?>
AddJavascriptFile('tools/bazar/libs/vendor/leaflet/spiderfier/oms.min.js');
$markersjs = 'var popups = Array();'."\n".'oms = new OverlappingMarkerSpiderfier(map'.$param['nbbazarliste'].');'."\n".
'var popup = new L.Popup();
oms.addListener("click", function(marker) {
marker.openPopup();
});
oms.addListener(\'spiderfy\', function(markers) {
map'.$param['nbbazarliste'].'.closePopup();
});'."\n";
} elseif ($param['cluster'] == 'true' or $param['cluster'] == '1') {
$GLOBALS['wiki']->AddCSSFile('tools/bazar/libs/vendor/leaflet/markercluster/MarkerCluster.css');
$GLOBALS['wiki']->AddJavascriptFile('tools/bazar/libs/vendor/leaflet/markercluster/leaflet.markercluster.js');
$markersjs = 'var markerscluster = new L.MarkerClusterGroup();'."\n";
} else {
$markersjs = '';
}
if ($param['fullscreen'] == 'true' || $param['fullscreen'] == '1') {
$param['fullscreen'] = 'true';
$GLOBALS['wiki']->AddCSSFile('tools/bazar/libs/vendor/leaflet/fullscreen/Control.FullScreen.css');
$GLOBALS['wiki']->AddJavascriptFile('tools/bazar/libs/vendor/leaflet/fullscreen/Control.FullScreen.js');
} else {
$param['fullscreen'] = 'false' ;
}
$i = 0;
foreach ($fiches as $fiche) :?>
'.$fiche['bf_titre'].'';
ob_start(); ?>
';
}
echo ' ' .$fiche['bf_adresse1'] .'
' .$fiche['bf_code_postal'] .' '.$fiche['bf_ville'].'
';
echo ' ' . $fiche['bf_tel'].'
';
echo ' ' .$fiche['bf_mail'] .'
';
$fiche['html'] .= '';
ob_end_clean();
$fiche['html'] .= '
Voir la fiche complète';
// couleur de marqueur
$color = getCustomValueForEntry($param['color'], $param['colorfield'], $fiche, $GLOBALS['wiki']->config['baz_marker_color']);
//icone de marqueur
$icon = $param['iconprefix']
.getCustomValueForEntry($param['icon'], $param['iconfield'], $fiche, $GLOBALS['wiki']->config['baz_marker_icon']);
$tab = explode('|', isset($fiche['carte_google']) ? $fiche['carte_google'] : '');
if (count($tab)>1 && $tab[0]!='' && $tab[1]!='' && is_numeric($tab[0]) && is_numeric($tab[1])) {
// on genere le point marqueur sur la carte
$markersjs .= '
i++;
var markerLocation = new L.LatLng('.$tab[0].', '.$tab[1].');
marker[i] = new L.Marker(
markerLocation,
{
icon: L.divIcon({
iconSize: '.$param['iconSize'].',
iconAnchor: '.$param['iconAnchor'].',
popupAnchor: '.$param['popupAnchor'].',
className: \'bazar-marker'.$param['smallmarker'].'\',
html: \''
.(!empty($icon) ? '' : '')
.'
\'
}),
title: '.json_encode($fiche['bf_titre']).'
});
marker[i].bindPopup('.json_encode(str_replace(array("\r", "\n"), '', $fiche['html'])).');
';
if ($param['spider'] == 'true' or $param['spider'] == '1') {
$markersjs .= 'map'.$param['nbbazarliste'].'.addLayer(marker[i]);'."\n".'oms.addMarker(marker[i]);'."\n";
} elseif ($param['cluster'] == 'true' or $param['cluster'] == '1') {
$markersjs .= 'markerscluster.addLayer(marker[i]);'."\n";
} else {
$markersjs .= 'map'.$param['nbbazarliste'].'.addLayer(marker[i]);'."\n";
}
$i++;
}
endforeach; ?>
AddJavascript( $js );
$js .= 'var layers = {};' ;
if( is_array($param['layers']) ){
$leafletajaxIncluded = false ;
foreach( $param['layers'] as $layer ) {
@list( $layerLabel, $layerType, $layerOptions, $layerUrl ) = explode('|', $layer);
if( $layerUrl == null ) {
$layerUrl = $layerOptions ;
$layerOptions = null ;
}
$layerType = strtolower($layerType);
if( ! in_array($layerType, array('tiles','geojson') ) ){
$js.= 'alert("Erreur paramètre \\"layers\\": le type \\"'.$layerType.'\\" est inconnu")';
}
switch($layerType)
{
case 'tiles':
$js.= 'layers["'.$layerLabel.'"] = L.tileLayer("'.$layerUrl.'");' ;
break;
case 'geojson':
// URL: Attention au Blocage d’une requête multi-origines (Cross-Origin Request).
// Le plus simple est de recopier les data GeoJson dans une page du Wiki puis de l'appeler avec le handler "/raw".
// STYLE:
// http://leafletjs.com/reference.html#path-options
// http://leafletjs.com/reference.html#marker-options
if( ! $leafletajaxIncluded ) {
$leafletajaxIncluded = true ;
$GLOBALS['wiki']->AddJavascriptFile('tools/bazar/libs/vendor/leaflet/ajax/dist/leaflet.ajax.min.js');
}
$styleJs = '' ;
if( $layerOptions!=null ){
$layerOptions = str_replace(';',',',$layerOptions);
$styleJs.='
style: function (feature, latlng) {
// pour les lignes et polygones
if( feature.geometry.type=="Point" )
return ;
return {'.$layerOptions.'};
},
pointToLayer: function (feature, latlng) {
// pour les points
// parsing de layerOptions pour distinguer les options de marker et celles pour construire un icon pour le marker.
var layerOptions = "'.$layerOptions.'".split(",");
var markerOptions = {} , iconClass=null, color=null ;
for( opt in layerOptions )
{
opt = layerOptions[opt].split(":");
switch(opt[0].trim()) {
case "opacity":
case "clickable":
// les options pour le marker http://leafletjs.com/reference.html#marker
markerOptions[opt[0].trim()] = opt[1].trim();
break;
case "icon":
// pour le html du L.divIcon http://leafletjs.com/reference.html#divicon
// supprimer les éventuels apostrhophes
iconClass = opt[1].trim().replace(/\'/g, "");
break;
case "color":
// pour le html du L.divIcon
color = opt[1].trim();
break;
}
}
if( iconClass!=null || color!=null ) {
// Construit un L.divIcon pour le marker, sinon ce sera par défaut la goutte bleu.
markerOptions["icon"] = L.divIcon({
iconSize: '.$param['iconSize'].',
iconAnchor: '.$param['iconAnchor'].',
popupAnchor: '.$param['popupAnchor'].',
className: "bazar-marker'.$param['smallmarker'].'",
html: "" + (iconClass==null?"":"") + "
"
});
}
return L.marker(latlng, markerOptions);
},
';
}
$js.= 'layers["'.$layerLabel.'"] = L.geoJson.ajax("'.$layerUrl.'",
{
'.$styleJs.'
onEachFeature: function (feature, layer) {
//layer.bindPopup(feature.properties.NOM + feature.properties.NOM_QP);
var str = "" ;
for( var prop in feature.properties){
if( prop.toLowerCase() == "url" ) {
str+= prop +": " + feature.properties[prop] +"
";
} else {
str+= prop +": "+ feature.properties[prop] +"
";
}
}
layer.bindPopup( str );
}
} );' ;
break;
}
}
}
$js.= 'L.control.layers(baseLayers, layers).addTo(map'.$param['nbbazarliste'].');' ;
} // else Avec un L.control.layers
$GLOBALS['wiki']->AddJavascript( '
$(document).ready(function() {
'.$js.'
// N\'ajoute pas un doublon de layer, mais active la sélection du layer.
map'.$param['nbbazarliste'].'.addLayer(provider);
map'.$param['nbbazarliste'].'.setView(new L.LatLng('.$param['latitude'].', '.$param['longitude'].'), '.$param['zoom'].');
var i = 0;
var marker = Array();
'. $markersjs .'
});'
);
if ($param['groupsexpanded'] == 'true' or $param['groupsexpanded'] == '1') {
$GLOBALS['wiki']->AddJavascript('
$(function(){
$("div.facette-container div.panel-collapse").collapse("show");
});
');
}
// echo '';
endif;
?>