Showing with 37 additions and 2 deletions.
  1. +22 −0 index.php
  2. +15 −2 js/mappa.js
22 changes: 22 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,28 @@
require_once ('varie.php');
do_head ('Homepage', array ('http://openlayers.org/api/OpenLayers.js', 'js/mappa.js'));

if (array_key_exists ('zoom', $_GET)) {
$found = false;
$contents = file ('dati.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);

foreach ($contents as $row) {
list ($lat, $lon, $lug, $useless) = explode (' ', $row, 4);
if ($lug == $_GET ['zoom']) {
$found = true;
break;
}
}

if ($found == true) {
?>

<input type="hidden" name="zooming_lat" value="<?php echo $lat ?>" />
<input type="hidden" name="zooming_lon" value="<?php echo $lon ?>" />

<?php
}
}

?>

<div id="map" class="smallmap"></div>
Expand Down
17 changes: 15 additions & 2 deletions js/mappa.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ OpenLayers.Feature.prototype.createPopup = function (closeBox) {
var id = this.id + "_popup";
var anchor = this.marker ? this.marker.icon : null;

this.popup = new (this.popupClass)(id, this.lonlat, this.data.popupSize, this.data.popupContentHTML, anchor, true);
this.popup = new OpenLayers.Popup.AnchoredBubble (id, this.lonlat, this.data.popupSize, this.data.popupContentHTML, anchor, true);
this.popup.autoSize = true;

if (this.data.overflow != null)
Expand Down Expand Up @@ -69,7 +69,20 @@ function init () {
var newl = new OpenLayers.Layer.Text( "LUG", {location: "./dati.txt"} );
map.addLayer(newl);

map.setCenter( lonLatToMercator(new OpenLayers.LonLat(12.483215,41.979911)),6);
if ($('input[name=zooming_lat]').length != 0) {
lat = $('input[name=zooming_lat]').val ();
lon = $('input[name=zooming_lon]').val ();
zoom = 12;
ll = new OpenLayers.LonLat(lon, lat);
}
else {
lon = 12.483215;
lat = 41.979911;
zoom = 6;
ll = lonLatToMercator(new OpenLayers.LonLat(lon, lat));
}

map.setCenter(ll, zoom);

if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition (
Expand Down