AJAX - actualizar marcadores de un mapa cada x tiempo

 
Vista:

actualizar marcadores de un mapa cada x tiempo

Publicado por german varas (2 intervenciones) el 22/10/2018 16:29:56
hola tengo el siguiente problema


tengo un mapa que recibe datos de una base de datos
latitud longitud etc
quisiera que ese mapa actualizara los marcadores sin tener que recargar la pagina
mando el codigo

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
<script>
function initMap() {
 
div = document.getElementById('flotante');
div2 = document.getElementById('nodo2');
div3 = document.getElementById('nodo3');
div4 = document.getElementById('nodo4');
div5 = document.getElementById('nodo5');
div6 = document.getElementById('nodo6');
div7 = document.getElementById('nodo7');
div8 = document.getElementById('nodo8');
div9 = document.getElementById('nodo9');
div10 = document.getElementById('nodo10');
 
var uluru10 = {lat:+ <?php 	print  $lati10;  ?>, lng: +<?php 	print  $longi10;  ?>};
var map = new google.maps.Map(document.getElementById('map'), {
  zoom: 15,
  center: {lat: + <?php 	print  $lati;  ?>, lng: +<?php 	print  $longi;  ?>}
});
 
var contentString = '<div id="content">'+
    '<div id="siteNotice">'+
    '</div>'+
    '<h5 id="firstHeading" class="firstHeading">Nodo n°1</h5>'+
    '<div id="bodyContent">'+
    '<p>Nombre nodo: <?php 	print  $nom1;  ?> </p>'+
    '</div>'+
    '</div>';
     var contentString2 = '<div id="content">'+
    '<div id="siteNotice">'+
    '</div>'+
    '<h5 id="firstHeading" class="firstHeading">Nodo n°2</h5>'+
    '<div id="bodyContent">'+
    '<p>Nombre nodo: <?php 	print  $nom2;  ?> </p>'+
    '</div>'+
    '</div>';
          var contentString3 = '<div id="content">'+
    '<div id="siteNotice">'+
    '</div>'+
    '<h5 id="firstHeading" class="firstHeading">Nodo n°3</h5>'+
    '<div id="bodyContent">'+
    '<p>Nombre nodo: <?php 	print  $nom3;  ?></p>'+
    '</div>'+
    '</div>';
          var contentString4 = '<div id="content">'+
    '<div id="siteNotice">'+
    '</div>'+
    '<h5 id="firstHeading" class="firstHeading">Nodo n°4</h5>'+
    '<div id="bodyContent">'+
    '<p>Nombre nodo: <?php 	print  $nom4;  ?></p>'+
    '</div>'+
    '</div>';
          var contentString5 = '<div id="content">'+
    '<div id="siteNotice">'+
    '</div>'+
    '<h5 id="firstHeading" class="firstHeading">Nodo n°5</h5>'+
    '<div id="bodyContent">'+
    '<p>Nombre nodo: <?php 	print  $nom5;  ?></p>'+
    '</div>'+
    '</div>';
          var contentString6 = '<div id="content">'+
    '<div id="siteNotice">'+
    '</div>'+
    '<h5 id="firstHeading" class="firstHeading">Nodo n°6</h5>'+
    '<div id="bodyContent">'+
    '<p>Nombre nodo: <?php 	print  $nom6;  ?></p>'+
    '</div>'+
    '</div>';
          var contentString7 = '<div id="content">'+
    '<div id="siteNotice">'+
    '</div>'+
    '<h5 id="firstHeading" class="firstHeading">Nodo n°7</h5>'+
    '<div id="bodyContent">'+
    '<p>Nombre nodo: <?php 	print  $nom7;  ?></p>'+
    '</div>'+
    '</div>';
          var contentString8 = '<div id="content">'+
    '<div id="siteNotice">'+
    '</div>'+
    '<h5 id="firstHeading" class="firstHeading">Nodo n°8</h5>'+
    '<div id="bodyContent">'+
    '<p>Nombre nodo: <?php 	print  $nom8;  ?></p>'+
    '</div>'+
    '</div>';
          var contentString9 = '<div id="content">'+
    '<div id="siteNotice">'+
    '</div>'+
    '<h5 id="firstHeading" class="firstHeading">Nodo n°9</h5>'+
    '<div id="bodyContent">'+
    '<p>Nombre nodo: <?php 	print  $nom9;  ?></p>'+
    '</div>'+
    '</div>';
          var contentString10 = '<div id="content">'+
    '<div id="siteNotice">'+
    '</div>'+
    '<h5 id="firstHeading" class="firstHeading">Nodo n°10</h5>'+
    '<div id="bodyContent">'+
    '<p>Nombre nodo: <?php 	print  $nom10;  ?></p>'+
    '</div>'+
    '</div>';
var infowindow = new google.maps.InfoWindow({
  content: contentString
});
    var infowindow2 = new google.maps.InfoWindow({
  content: contentString2
});
    var infowindow3 = new google.maps.InfoWindow({
  content: contentString3
});
 var infowindow4 = new google.maps.InfoWindow({
  content: contentString4
});
 var infowindow5 = new google.maps.InfoWindow({
  content: contentString5
});
 var infowindow6 = new google.maps.InfoWindow({
  content: contentString6
});
 var infowindow7 = new google.maps.InfoWindow({
  content: contentString7
});
    var infowindow8 = new google.maps.InfoWindow({
  content: contentString8
});
    var infowindow9 = new google.maps.InfoWindow({
  content: contentString9
});
    var infowindow10 = new google.maps.InfoWindow({
  content: contentString10
});
 
var marker = new google.maps.Marker({
  position: {lat: + <?php 	print  $lati;  ?>, lng: +<?php 	print  $longi;  ?>},
  map: map,
  title: 'Nodo 1'
});
 
     var marker2 = new google.maps.Marker({
  position:{lat: + <?php 	print  $lati2;  ?>, lng: +<?php 	print  $longi2;  ?>},
  map: map,
  title: 'Nodo 2'
});
     var marker3 = new google.maps.Marker({
  position:{lat: + <?php 	print  $lati3;  ?>, lng: +<?php 	print  $longi3;  ?>},
  map: map,
  title: 'Nodo 3'
});
     var marker4 = new google.maps.Marker({
  position:{lat: + <?php 	print  $lati4;  ?>, lng: +<?php 	print  $longi4;  ?>},
  map: map,
  title: 'Nodo 4'
});
     var marker5 = new google.maps.Marker({
  position:{lat: + <?php 	print  $lati5;  ?>, lng: +<?php 	print  $longi5;  ?>},
  map: map,
  title: 'Nodo 5'
});
   var marker6 = new google.maps.Marker({
  position:{lat: + <?php 	print  $lati6;  ?>, lng: +<?php 	print  $longi6;  ?>},
  map: map,
  title: 'Nodo 6'
});
   var marker7 = new google.maps.Marker({
  position:{lat: + <?php 	print  $lati7;  ?>, lng: +<?php 	print  $longi7;  ?>},
  map: map,
  title: 'Nodo 7'
});
   var marker8 = new google.maps.Marker({
  position:{lat: + <?php 	print  $lati8;  ?>, lng: +<?php 	print  $longi8;  ?>},
  map: map,
  title: 'Nodo 8'
});
   var marker9 = new google.maps.Marker({
  position:{lat: + <?php 	print  $lati9;  ?>, lng: +<?php 	print  $longi9;  ?>},
  map: map,
  title: 'Nodo 9'
});
   var marker10 = new google.maps.Marker({
  position: uluru10,
  map: map,
  title: 'Nodo 10'
});
 
 
}
 
</script>
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder