ต่อจากบทความที่แล้ว
Go to : การสร้าง Marker จุดพิกัดจาก Lat Long อย่างง่ายด้วย Google map V3
เพิ่ม Google Earth Api ให้กับ Google Map เพื่อให้แสดง Multi Map และ Multi Marker Google map
Code
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Google Map Test by Deawx</title>
<style type="text/css">
html {
height: auto;
}
body {
height: auto;
margin: 0;
padding: 0;
}
#map {
height: auto;
position: absolute;
bottom:0;
left:0;
right:0;
top:0;
}
@media print {
#map {
height: 950px;
}
}
</style>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript"
src="https://www.google.com/jsapi?key=ABQIAAAA_KNcKfoyaTskjEp-kSSEjxSsDbTxMRg-JrUcPZT14QWonZA5mxRqx3ct_DbeHVelXNr1WbKEEJ5k-A"></script>
<script src="http://google-maps-utility-library-v3.googlecode.com/svn/trunk/googleearth/src/googleearth-compiled.js" type="text/javascript"></script>
<script type="text/javascript">
google.load('earth', '1');
var map;
var googleEarth;
function init() {
map = new google.maps.Map(document.getElementById('map'), {
zoom: 10,
center: new google.maps.LatLng(15.105355046221582, 104.31570053100586),
zoom: 13,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
googleEarth = new GoogleEarth(map);
var locations = [
['<a href="http://www.google.co.th">สี่แยก หนองครก</a>', 15.09234482843765, 104.30643081665039, 1],
['วิทยาลัยเทคนิคศรีสะเกษ', 15.10769597211894, 104.3216872215271, 2],
['โรงพยาบาลจังหวัดศรีสะเกษ', 15.11544363118582, 104.32016372680664, 3]
];
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]),
draggable : false,
title : locations[i][0],
icon : 'http://maps.google.com/mapfiles/kml/pal3/icon48.png',
map: map
});
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
infowindow.setContent(locations[i][0]);
infowindow.open(map, marker);
}
})
(marker, i));
}
}
google.maps.event.addDomListener(window, 'load', init);
</script>
</head>
<body>
<div id="map"></div>
</body>
</html>
deawx
[email protected]
ปรึกษา PHP ฟรีจ้า