它只显示一个空白的灰色块。虽然它在Chrome和Mozilla Firefox中运行良好。
这是我的代码,假设URI段(2)是mi,而段(3)是allen-park:
<div style="border: 1px solid #999">
<div id="map_canvas" style="width: 100%; height: 300px; position: relative; background-color: rgb(229, 227, 223);"></div>
</div>
<script type="text/javascript">
$(document).ready(function () {
$.getJSON( "http://maps.google.com/maps/api/geocode/json?address=<?php echo $this->uri->segment(3) ?>,<?php echo $this->uri->segment(2) ?>&sensor=false", function( json ) {
var coordinates = json.results[0].geometry.location;
var latlng = new google.maps.LatLng(coordinates.lat, coordinates.lng);
var myOptions = { zoom: 12, center: latlng,scrollwheel: false, mapTypeId: google.maps.MapTypeId.ROADMAP };
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
});
});
</script>