它只显示一个空白的灰色块。虽然它在 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>