Commit d52a18a1 authored by Loïc DAYOT's avatar Loïc DAYOT Committed by Ploc
Browse files

chore(): move default map parameters in config.inc.php

Map parameters (zoom, lat, lon) are now set in local configuration file for easier configuration. Add a message when geolocation isn't found from address.

BREAKING CHANGE:

Add the following configuration in your `www/inc/config.inc.php` file in line 99:

```php
/*
 * Map settings
 **/
$mapGlobalDisplay = array( /** in map.php */
    'lat'     => 46.8,
    'lon'     => 1,
    'zoom'    => 6,
);
$mapLocalgroupDisplay = array( /** in showlocalgroup */
    'zoom'    => 13,
);
$mapEventDisplay = array( /** in showevent */
    'zoom'    => 11,
);
```
parent 28051cc0
<?php
/*
* Copyright 2014-2016
* Copyright 2014-2017
* - Loic Dayot <ldayot CHEZ epnadmin POINT net>
*
* This file is part of agenda-libre-php.
......@@ -190,6 +190,7 @@ class geocode {
if (! isset($object->latitude, $object->longitude)) {
$object->latitude = $object->longitude = 0;
}
$mapElementZoom = max($GLOBALS['mapEventDisplay']['zoom'], $GLOBALS['mapLocalgroupDisplay']['zoom']);
$html = <<<MAPINPUT
<div style="margin: auto; width:90%; height:320px; border: 1px solid black;" id="map"></div>
......@@ -198,6 +199,10 @@ class geocode {
var fieldName = '$fieldName';
var latitude = {$object->latitude};
var longitude = {$object->longitude};
var mapElementZoom = {$mapElementZoom};
var lat={$GLOBALS['mapGlobalDisplay']['lat']}
var lon={$GLOBALS['mapGlobalDisplay']['lon']}
var zoom={$GLOBALS['mapGlobalDisplay']['zoom']}
</script>
<input name='{$fieldName}[lon]' type='hidden' value="{$object->longitude}" />
<input name='{$fieldName}[lat]' type='hidden' value="{$object->latitude}"/>
......
<?php
/*
* Copyright 2008-2016
* Copyright 2008-2017
* - Thomas Petazzoni <thomas POINT petazzoni CHEZ enix POINT org>
* - Loic Dayot <ldayot CHEZ epnadmin POINT net>
*
......@@ -96,4 +96,19 @@ $timezone = "Europe/Paris"; /* default timezone used to get actual time (not the
see <http://php.net/manual/fr/timezones.php> for a list of valid timezones */
/*
* Map settings
**/
$mapGlobalDisplay = array( /** in map.php */
'lat' => 46.8,
'lon' => 1,
'zoom' => 6,
);
$mapLocalgroupDisplay = array( /** in showlocalgroup */
'zoom' => 13,
);
$mapEventDisplay = array( /** in showevent */
'zoom' => 11,
);
?>
......@@ -193,7 +193,7 @@ function menu_html()
$r .= "- <a class='list-group-item' href='moderation.php?disconnect=1'><i class='fa fa-sign-out'></i>&nbsp;Se déconnecter</a><br/>\n";
}
$r .= "<a class='list-group-item big' href=\"submit.php\"><i class='fa fa-pencil'></i>&nbsp;Proposer un évènement</a> (publication après modération)";
if ($localgroupSubmit) {
if ($localgroupManagement & $localgroupSubmit) {
$r .= " - <a class='list-group-item' href=\"moderatelocalgroups.php?op=new\"><i class='fa fa-users'></i>&nbsp;Proposer un {$adl_localgroup}</a>";
}
$r .= "<br />\n";
......
......@@ -50,9 +50,6 @@ OpenLayers.Layer.OSM.Mapnik = OpenLayers.Class(OpenLayers.Layer.OSM, {
});
/* Display map */
var lat=46.8
var lon=1
var zoom=6
var map, markers, icon;
var lonlat;
......@@ -73,7 +70,7 @@ function init() {
if (latitude!=0) {
var lonLatPoint = new OpenLayers.LonLat(longitude, latitude).transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913"));
markers.addMarker(new OpenLayers.Marker(lonLatPoint));
zoom = 10;
zoom = mapElementZoom;
lat = latitude;
lon = longitude;
}
......@@ -153,7 +150,7 @@ function searchPlace(lonlat) {
success:function(e){
if(e.error){ /* si aucun résultats, on renvoi un tableau vide pour informer qu'on a rien trouvé */
var result = {
place: 'Aucune adresse trouvée...',
place: 'Aucune adresse trouvée... pointez directement sur la carte',
display_name: null,
city: null,
postcode: null,
......@@ -262,9 +259,8 @@ function autoLoFill(i) {
var lonLatPoint = new OpenLayers.LonLat(lon, lat).transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913"));
markers.clearMarkers();
markers.addMarker(new OpenLayers.Marker(lonLatPoint));
zoom = 12;
var lonLat = new OpenLayers.LonLat(lon, lat).transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913"));
map.setCenter (lonLat, zoom);
map.setCenter (lonLat, mapElementZoom);
return false;
}
......
<?php
/*
* Copyright 2004-2015
* Copyright 2004-2017
* - Mélanie Bats <melanie POINT bats CHEZ utbm POINT fr>
* - Thomas Petazzoni <thomas POINT petazzoni CHEZ enix POINT org>
* - Loic Dayot <ldayot CHEZ ouvaton POINT org>
......@@ -28,9 +28,9 @@ $jcode = "
<script src=\"https://openlayers.org/api/OpenLayers.js\"></script>
<script src=\"https://openstreetmap.org/openlayers/OpenStreetMap.js\"></script>
<script type=\"text/javascript\">
var lat=46.8
var lon=1
var zoom=6
var lat={$GLOBALS['mapGlobalDisplay']['lat']}
var lon={$GLOBALS['mapGlobalDisplay']['lon']}
var zoom={$GLOBALS['mapGlobalDisplay']['zoom']}
var map;
function init() {
map = new OpenLayers.Map (\"map\", {
......
......@@ -61,7 +61,7 @@ if ($event->latitude>0)
<script type=\"text/javascript\">
var lat={$event->latitude}
var lon={$event->longitude}
var zoom=11
var zoom={$GLOBALS['mapEventDisplay']['zoom']}
var map;
function init() {
map = new OpenLayers.Map (\"map\", {
......
<?php
/*
* Copyright 2016
* Copyright 2016-2017
* - Loic Dayot <ldayot A epnadmin POINT net>
*
* This file is part of agenda-libre-php.
......@@ -42,7 +42,7 @@ if ($localgroup->latitude>0)
<script type=\"text/javascript\">
var lat={$localgroup->latitude}
var lon={$localgroup->longitude}
var zoom=13
var zoom={$GLOBALS['mapLocalgroupDisplay']['zoom']}
var map;
function init() {
map = new OpenLayers.Map (\"map\", {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment