You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

104 lines
3.8 KiB

<BOUCLE_gis(GIS){objet ?}{id_objet ?}{id_gis ?}{0,1}>
<div id="map_preview" class="carte_gis" style="width: 100%; height: 150px;"></div>
<script type="text/javascript">
<!--
(function($){
var init_map_preview = function() {
var map_preview;
var map_preview_container = 'map_preview';
var marker;
map_preview = new L.Map(map_preview_container);
map_preview.attributionControl.setPrefix('');
var base_layer = [new (#EVAL{$GLOBALS\['gis_layers'\]}|table_valeur{[(#REM|gis_layer_defaut)]/layer})];
map_preview.addLayer(base_layer);
map_preview.setView(new L.LatLng([(#LAT)],[(#LON)]),[(#ZOOM|sinon{#CONFIG{gis/zoom,0}})]);
[(#REM) On ajoute les points ou le point unique suivant les params ]
<B_points>
var data = {
"type": "FeatureCollection",
"features": [
<BOUCLE_points(GIS){id_objet}{objet}{","}>
{"type": "Feature",
"geometry": {"type": "Point", "coordinates": [#LON, #LAT]},
"id":"#ID_GIS",
"properties": {
"title":[(#TITRE|supprimer_numero|json_encode)],
"description":[(#DESCRIPTIF|json_encode)][,(#LOGO_GIS|oui)
[(#SET{logo_doc,#LOGO_GIS|image_passe_partout{28,28}|image_recadre{28,28}|image_recadre{32,32,center}|image_aplatir{jpg,ffffff}})]
#SET{icon_w,#GET{logo_doc}|extraire_attribut{src}|largeur}
#SET{icon_h,#GET{logo_doc}|extraire_attribut{src}|hauteur}
["icon": (#GET{logo_doc}|extraire_attribut{src}|url_absolue|json_encode)],
"icon_size": \[#GET{icon_w},#GET{icon_h}\],
"icon_anchor": \[[(#GET{icon_w}|div{2})],[(#GET{icon_h})]\]]
}
}
</BOUCLE_points>
]
};
[(#TOTAL_BOUCLE|>{1}|oui) #SET{autocenter,oui} ]
</B_points>
<BOUCLE_point(GIS){id_gis}>
var data = {
"type": "FeatureCollection",
"features": [
{"type": "Feature",
"geometry": {"type": "Point", "coordinates": [#LON, #LAT]},
"id":"#ID_GIS",
"properties": {
"title":[(#TITRE|supprimer_numero|json_encode)],
"description":[(#DESCRIPTIF|json_encode)][,(#LOGO_GIS|oui)
[(#SET{logo_doc,#LOGO_GIS|image_passe_partout{28,28}|image_recadre{28,28}|image_recadre{32,32,center}|image_aplatir{jpg,ffffff}})]
#SET{icon_w,#GET{logo_doc}|extraire_attribut{src}|largeur}
#SET{icon_h,#GET{logo_doc}|extraire_attribut{src}|hauteur}
["icon": (#GET{logo_doc}|extraire_attribut{src}|url_absolue|json_encode)],
"icon_size": \[#GET{icon_w},#GET{icon_h}\],
"icon_anchor": \[[(#GET{icon_w}|div{2})],[(#GET{icon_h})]\]]
}
}]
};
</BOUCLE_point>
<//B_points>
if (data) {
var geojson = new L.geoJson('', {
onEachFeature: function (feature, layer) {
if (feature.properties && feature.properties.icon){
layer.setIcon(new L.Icon({
iconUrl: feature.properties.icon,
iconSize: new L.Point( feature.properties.icon_size\[0\], feature.properties.icon_size\[1\] ),
iconAnchor: new L.Point( feature.properties.icon_anchor\[0\], feature.properties.icon_anchor\[1\] ),
}));
}
if (feature.properties && feature.properties.title){
layer.bindPopup(feature.properties.title);
}
}
}).addTo(map_preview);
geojson.addData(data);
[(#GET{autocenter}|oui)
map_preview.fitBounds(geojson.getBounds());]
}
[(#REM) On ajoute les KML attachés à l'objet ]
<BOUCLE_kml(DOCUMENTS){tous}{objet}{id_objet}{extension=kml}>
map_preview.addLayer(new L.KML('[(#URL_DOCUMENT|url_absolue)]', {async: true}));
</BOUCLE_kml>
[(#REM) On ajoute les GPX attachés à l'objet ]
<BOUCLE_gpx(DOCUMENTS){tous}{objet}{id_objet}{extension=kml}>
map_preview.addLayer(new L.GPX('[(#URL_DOCUMENT|url_absolue)]', {async: true}));
</BOUCLE_gpx>
}
$(function(){
init_map_preview();
//onAjaxLoad(init_map_preview(true));
});
})(jQuery);
-->
</script>
</BOUCLE_gis>