4
I’m creating a site where I need a map, and users fill in forms with latitude and longitude to create a point on that same map. Everything is stored in the database but I needed the name of the point, the latitude and the longitude to pass before in an array. That is, data saved in a database but always running in the array. My code is this::
<html>
<?php include("header.php");?>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>Google Maps </title>
<script src="http://maps.google.com/maps/api/js?key=AIzaSyDTXwZGf67oO-63Ci_OfR7CzB7Wm003Gow&sensor=false"
type="text/javascript"></script>
</head>
<body>
<div class="content">
<h1><b>Roteiro Definido</b></h1>
<hr/>
<div style="float: left;">
<h2><b>Indicações</b></h2>
<dl>
<dt><b>Nome do Local</b></dt>
<dd>-------------</dd>
<dt><b>Tipo de Local</b></dt>
<dd>-------------</dd>
<dt><b>Moradado Local</b></dt>
<dd>---------------</dd>
<dt><b>Código Postal e Localidade</b></dt>
<dd>--------------------------</dd>
</dl></div>
<div id="map" style="width: 500px; height: 400px; float: right;"></div>
<script type="text/javascript">
var locations = [
['Parque estacionamento', 41.69114219999999, -8.828242600000067, 3],
['Praia do Norte', 41.696997, -8.850979000000052, 2],
['Navio Gil Eanes', 41.69009, -8.830255999999963, 1]
];
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 10,
center: new google.maps.LatLng(41.694808, -8.830981),
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var infowindow = new google.maps.InfoWindow();
var marker, i;
for (i = 0; i < locations.length; i++) {
marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i][1], locations[i][2]),
map: map
});
google.maps.event.addListener(marker, 'click', (function (marker, i) {
return function () {
infowindow.setContent(locations[i][0]);
infowindow.open(map, marker);
}
})(marker, i));
}
</script>
</body>
</html>
</div>
<?php include("footer.php");?>
You made the
ajax
to return this data ?– Diego Souza
You should use ajax for that Melissa
– Miguel
@Diegosouza Good afternoon, no, I’ll leave the whole code to see, I’ll edit the question
– Melissa Sousa
@Miguel Abe show me how to do it? I’ve never used ajax
– Melissa Sousa
I’ll try to help
– Miguel