source: trunk/client/inc/javascript.php

Last change on this file was 247, checked in by luc, 8 years ago

Aggiornato Google Maps e sistemato in amministrazione la scelta del tema.
Solo per l'upgrade temete conto del file di aggirnamento del databalse presente nella dir sql con il nome aggiornamento-2.0_2016-01-30.sql.

File size: 3.9 KB
Line 
1<?php
2/************************************************************************/
3/* Eleonline - Raccolta e diffusione dei dati elettorali */
4/* by Luciano Apolito & Roberto Gigli */
5/* http://www.eleonline.it */
6/* info@eleonline.it luciano@aniene.net rgigli@libero.it */
7/************************************************************************/
8
9if (stristr(htmlentities($_SERVER['PHP_SELF']), "javascript.php")) {
10 Header("Location: ../index.php");
11 die();
12}
13
14##################################################
15# Include funzioni javascript #
16##################################################
17#timer per tema tour
18# inizio rotazione
19if (isset($_SESSION['ruota']))
20{
21?>
22
23 <script type="text/javascript" language="javascript">
24<!--
25function loadpage() {
26
27thetimer = setTimeout("changepage()", 20000);
28
29
30}
31
32function changepage() {
33
34newlocation = "<?php echo "modules.php?csv=1&block=0&id_cons_gen=".$_GET['id_cons_gen']."&id_comune=".$_GET['id_comune']; ?>"
35location = newlocation
36}
37// --></script>
38
39<?php
40}
41# fine rotazione
42# googlemaps per sezioni
43# variabili nel config.php
44# gkey= chiave google reperibile per il proprio sito qui
45# http://code.google.com/intl/it/apis/maps/signup.html
46# googlemaps 1=attivo 2: disattivo
47# funzione by eleonline.it
48#########################################################
49
50
51
52
53
54
55
56function googlemaps(){
57global $dbi,$prefix,$id_comune,$googlemaps,$op,$gkey,$lang;
58# recupera gli inidirizzi
59 $id_sede=$_GET['id_sede'];
60 $sql = mysql_query("SELECT descrizione FROM ".$prefix."_ele_comuni where id_comune='$id_comune' ", $dbi);
61 list($comune) = mysql_fetch_row($sql);
62 $sql = mysql_query("select indirizzo from ".$prefix."_ele_sede where id_sede='$id_sede'", $dbi);
63 list($indirizzo)=mysql_fetch_row($sql);
64 $address=rawurlencode("$indirizzo,$comune,58047");
65
66 $resultGeoCode=file_get_contents('http://maps.google.com/maps/api/geocode/json?address='.$address.'&amp;sensor=false');
67
68 $output= json_decode($resultGeoCode);
69
70 if($output->status == 'OK'){
71 $latitude = $output->results[0]->geometry->location->lat; //Returns Latitude
72 $longitude = $output->results[0]->geometry->location->lng; // Returns Longitude
73 $location = $output->results[0]->formatted_address;
74 }
75
76
77 $coords['lat'] = $latitude;
78 $coords['long'] = $longitude;
79
80
81
82
83
84/*
85
86
87
88
89 $url = sprintf('http://maps.google.com/maps?output=js&q=%s',rawurlencode($address));
90 $result = false;
91
92 if($result = file_get_contents($url)) {
93 $coords = array();
94
95 if(strpos($result,'errortips') > 1 || strpos($result,'Did you mean:') !== false) {
96 return false;
97 }
98
99 preg_match('!center:\s*{lat:\s*(-?\d+\.\d+),lng:\s*(-?\d+\.\d+)}!U', $result, $matches);
100
101 $coords['lat'] = $matches[1];
102 $coords['long'] = $matches[2];
103 }
104
105*/
106
107
108
109
110
111
112
113echo '
114<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true&language=it"></script>
115 <script type="text/javascript">
116 function maps() {
117 var latlng = new google.maps.LatLng('.$coords['lat'].','.$coords['long'].'); // centro della mappa
118 var myLatlng = new google.maps.LatLng('.$coords['lat'].','.$coords['long'].'); // segnapunto
119 // definizione della mappa
120 var myOptions = {
121 zoom: 16,
122 center: latlng,
123 mapTypeId: google.maps.MapTypeId.ROADMAP,
124 mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR}
125 }
126 mymap = new google.maps.Map(document.getElementById("map"), myOptions);
127 // definizione segnapunto
128 var marker = new google.maps.Marker({
129 position: myLatlng,
130 map: mymap,
131 title:"'.$address.'"
132 });
133
134 }
135 </script>
136';
137
138}
139?>
Note: See TracBrowser for help on using the repository browser.