|
|
|
อยากให้กดลิ้งต่อไปได้หลังจาก infowindow แสดง(Google map) |
|
|
|
|
|
|
|
Code (PHP)
<!DOCTYPE html>
<html>
<head>
<title>Simple Map</title>
<meta name="viewport" content="initial-scale=1.0">
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<meta charset="utf-8">
<style>
/* Always set the map height explicitly to define the size of the div
* element that contains the map. */
#map {
height: 100%;
}
/* Optional: Makes the sample page fill the window. */
html {
height: 100%;
margin: 0px;
padding: 0px;
text-align: center;
}
#map {
height: 620px;
width: 1350px;
}
</style>
</head>
<body>
<div id="map"></div>
<script>
function initMap() {
var mapOptions = {
center: {lat: 13.847860, lng: 100.604274},
zoom:6,
}
var maps = new google.maps.Map(document.getElementById("map"),mapOptions);
var marker, info;
var arr=[];
<?php
include"connect.php";
if(array_key_exists('Label', $_GET)){
$Label = $_GET['Label'];
$query="SELECT * FROM map2 WHERE Label = '$Label' limit 1";
$result = mysqli_query($con,$query);
while($row = mysqli_fetch_array($result)) {
?>
$.getJSON( "json.php?Label=<?php echo $row["Label"]?>", function( jsonObj ) {
//*** loop
$.each(jsonObj, function(i, item){
var marker = new google.maps.Marker({
position: new google.maps.LatLng(item.la, item.lo),
map: maps,
title: item.Temple_name,
icon: 'busIcon57.png'
});
var info = new google.maps.InfoWindow();
arr.push(marker.getPosition());
var poly = new google.maps.Polyline({
path: arr,
strokeColor: '#FF6600',
strokeOpacity: 1.0,
strokeWeight: 6,
map: maps
});
function setMapsToCenter(obj) {
var bounds = new google.maps.LatLngBounds();
var points = obj.getPath().getArray();
for (var n = 0; n < points.length; n++) {
bounds.extend(points[n]);
}
map.fitBounds(bounds);//เส้น Polyline จะถูกสร้างจริงจากคำสั่งนี้ครับ
}
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
info.setContent(item.Temple_name);
info.open(maps, marker);
}
})(marker,i));
/////////////////---------------------each------------------------//////////////////////////////
});
});
//setMapsToCenter(poly);
}
<?php }}?>
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyC6eOHYHZk7N7G1L6WTN5B9X2EKYLSznaM&callback=initMap" async defer></script>
</body>
</html>
Tag : PHP
|
|
|
|
|
|
Date :
2018-11-09 17:28:35 |
By :
Bombermanzzzzzzz |
View :
733 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอภาพประกอบหน่อยครับ
|
|
|
|
|
Date :
2018-11-20 17:56:02 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|