0
我在PHP的城市列表,以在地圖上顯示多個城市:如何使用谷歌地圖API V3
$cities = array(0=>"Absecon,NJ",1=>"Alamogordo,NJ",2=>"Atlantic city,NJ....);
我要在地圖上顯示我的所有城市,是可能的,如果我不有經緯度嗎?
我初始化地圖這樣:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0; padding: 0 }
#map_canvas { height: 100% }
</style>
<script type="text/javascript"
src="http://maps.googleapis.com/maps/api/js?key=MY_API_KEY&sensor=true">
</script>
<script type="text/javascript">
function initialize() {
var countries = '<?php echo json_enconde($cities);?>';
var mapOptions = {
center: new google.maps.LatLng(-34.397, 150.644),
zoom: 2,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas"),mapOptions);
}
</script>
</head>
<body onload="initialize()">
<div id="map_canvas" style="width:100%; height:100%"></div>
</body>
</html>