map.js
function loadMap() {
var location = new google.maps.LatLng(13, 100);
var mapType = google.maps.MapTypeId.ROADMAP;
var zoomLevel = 6;
var map = createMap(location, zoomLevel, mapType);//***
}
function createMap(location, zoomLevel, mapType){
var options = {
center: location,
zoom: zoomLevel,
mapTypeId: mapType
};
var map = new google.maps.Map(document.getElementById("myMap"), options);
return map;
}
map.html
<!-- first map -->
<html>
<head>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&sensor=TRUE_OR_FALSE"></script>
<script type="text/javascript" src="js/map.js"></script>
</head>
<body onload="loadMap()">
<div id="myMap" style="width:100%; height:500px"></div>
</body>
</html>
ไม่มีความคิดเห็น:
แสดงความคิดเห็น