google'map in php (thinkphp5)
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=7" />
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta name="description" content=" " />
<title>谷歌地圖 api測試</title>
<style>
.map {
width: 1200px;
height: 800px;
text-align: center;
margin: 0 auto;
}
</style>
</head>
<body>
<div id="res_map" class="map"></div>
<script src="http://ditu.google.cn/maps?file=api&v=2&&key=ABQIAAAAHDyarwhqc8qoi6Hi4Fw2ABS7hG4ulivpH-Zy5ZAv91XflKVwfhRT3BrS_8CE9kMWp7UXsEngXSYF3A" type="text/javascript" charset="utf-8"></script>
<!-- key 要自己去google 去申請。申請需要翻牆-->
<script type="text/javascript" charset="utf-8">
function show_small_map()
{
if (GBrowserIsCompatible())
{
var map = new GMap2(document.getElementById("res_map"));
function createMarker(latlng)
{
var marker = new GMarker(latlng);
return marker;
}
map.setCenter(new GLatLng(23.1150614,113.4082905), 16);
var smc = new GSmallZoomControl3D;
map.addControl(smc);
var latlng = new GLatLng(23.1150614,113.4082905);
map.addOverlay(createMarker(latlng));
}
}
show_small_map();
</script>
</body>
</html>
自己建controller,模板,Map->index.html。其他頁面直接{include file="map/index" /}