-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathafegir_museu.php
More file actions
188 lines (160 loc) · 7.24 KB
/
afegir_museu.php
File metadata and controls
188 lines (160 loc) · 7.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
<?
session_start();
if($_SESSION['logged'])
{
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="styles.css" rel="stylesheet" type="text/css">
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type='text/javascript' src='menu_jquery.js'></script>
<title>Afegir Museu</title>
<script type="text/javascript">
//Declaramos las variables que vamos a user
var lat = null;
var lng = null;
var map = null;
var geocoder = null;
var marker = null;
jQuery(document).ready(function(){
//obtenemos los valores en caso de tenerlos en un formulario ya guardado en la base de datos
lat = jQuery('#lat').val();
lng = jQuery('#long').val();
//Asignamos al evento click del boton la funcion codeAddress
jQuery('#pasar').click(function(){
codeAddress();
return false;
});
//Inicializamos la función de google maps una vez el DOM este cargado
initialize();
});
function initialize() {
geocoder = new google.maps.Geocoder();
//Si hay valores creamos un objeto Latlng
if(lat !='' && lng != '')
{
var latLng = new google.maps.LatLng(lat,lng);
}
else
{
var latLng = new google.maps.LatLng(41.3866634,2.1639244000000417);
}
//Definimos algunas opciones del mapa a crear
var myOptions = {
center: latLng,//centro del mapa
zoom: 15,//zoom del mapa
mapTypeId: google.maps.MapTypeId.ROADMAP //tipo de mapa, carretera, híbrido,etc
};
//creamos el mapa con las opciones anteriores y le pasamos el elemento div
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
//creamos el marcador en el mapa
marker = new google.maps.Marker({
map: map,//el mapa creado en el paso anterior
position: latLng,//objeto con latitud y longitud
draggable: true //que el marcador se pueda arrastrar
});
//función que actualiza los input del formulario con las nuevas latitudes
//Estos campos suelen ser hidden
updatePosition(latLng);
}
//funcion que traduce la direccion en coordenadas
function codeAddress() {
//obtengo la direccion del formulario
var address = document.getElementById("direccion").value;
//hago la llamada al geodecoder
geocoder.geocode( { 'address': address}, function(results, status) {
//si el estado de la llamado es OK
if (status == google.maps.GeocoderStatus.OK) {
//centro el mapa en las coordenadas obtenidas
map.setCenter(results[0].geometry.location);
//coloco el marcador en dichas coordenadas
marker.setPosition(results[0].geometry.location);
//actualizo el formulario
updatePosition(results[0].geometry.location);
//Añado un listener para cuando el markador se termine de arrastrar
//actualize el formulario con las nuevas coordenadas
google.maps.event.addListener(marker, 'dragend', function(){
updatePosition(marker.getPosition());
});
} else {
//si no es OK devuelvo error
alert("No podemos encontrar la dirección, error: " + status);
}
});
}
//funcion que simplemente actualiza los campos del formulario
function updatePosition(latLng)
{
jQuery('#lat').val(latLng.lat());
jQuery('#long').val(latLng.lng());
}
</script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-1749329-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>
<?php include "barra_menu.php";//Incloem la barra del menu ?>
<center>
<h1> Afegir Museu </h1>
<?php
if(isset($_GET["err"])){
$err = $_GET["err"];
if($err == "0"){
echo "<font color=\"green\"> Museu Afegit Correctament!!</font>";
}else if($err == "1"){
echo "<font color=\"red\"> Falten Camps! </font>";
}
}
?>
<div id='Formulari_m'>
<form id="subirImg" name="subirImg" enctype="multipart/form-data" method="post" action="php/serv_afegirMuseu.php">
<input id="element_form" name="nom" type="text" placeholder="Nom Museu"/>
<input id="element_form" name="telefon" type="text" placeholder="Telefon"/>
<input style="width:300px" type="text" id="direccion" name="direccion" placeholder="Direcció" value=""/>
<br>
<br>
<button id="pasar">Obtenir Coordenades</button>
<label>Latitud: </label><input type="text" readonly name="lat" id="lat"/>
<label> Longitud:</label> <input type="text" readonly name="lng" id="long"/>
<a href="#google">Veure mapa</a>
<br>Horari laboral:
<input id="element_form" name="hor_lab_inici" type="text" maxlength="4" style="margin-left:20px; width:50px;"placeholder="Hora Inici"/>
<input id="element_form" name="hor_lab_fi" type="text" maxlength="4" style="width:50px;" placeholder="Hora fi"/>
Horari festius:
<input id="element_form" name="hor_fes_inici" type="text" maxlength="4" style="margin-left:20px;width:50px;" placeholder="Hora Inici"/>
<input id="element_form" name="hor_fes_fi" type="text" maxlength="4" style="width:50px;"placeholder="Hora fi"/>
<br>Wifi?
<input type="checkbox" name="teWifi" value="true">
<input id="element_form" name="wifiSsid" type="password" placeholder="wifi ssid"/>
<input id="element_form" name="passWifi" type="password" placeholder="Pass Wifi"/>
<br><h3>Imatge:</h3><input type="file" style="margin-left:20px;" name="imagen" id="imagen" />
<textarea rows="18" cols="100" id="info" name="info" tabindex="200" placeholder="Info..."></textarea><br>
<input type="submit" id="button" name="subirBtn" id="subirBtn" value="Afegir Museu" />
</form>
<br><br><br>
<h1>Posició del Museu</h1>
<form id="google" name="google" action="#">
<div id="map_canvas" style="width:800px;height:300px;"></div>
<br><br><br>
<br><br><br>
</form>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
</div>
<center>
</body>
</html>
<?
} else {
header("Location: index.php");
}
?>