私は私の緯度と経度を経由して取得しています:
$geocode = file_get_contents('http://maps.google.com/maps/api/geocode/json?address=' . $g_location . '&sensor=true');
$output= json_decode($geocode);
$lat = $output->results[0]->geometry->location->lat;
$long = $output->results[0]->geometry->location->lng;
正しい緯度と経度を返します。だから今、私は自分の地図を作成しようとしています:
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCTQqh2ksk9ZTqSfx-_ki_lHj-q32kYIY8&sensor=false"> </script>
<script language="JavaScript">
var map;
function initialize() {
var mapOptions = {
zoom: 8,
center: new google.maps.LatLng(<?=$lat?>, <?=$long?>),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('map_canvas'),
mapOptions);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
HTML:
div id="map_canvas"></div>
何も表示されていません。私は何かが足りないのですか?
ありがとう。