Google 地图 API Javascript - 地图未显示
我的网页中有以下代码 - 地图 div 没有显示谷歌地图,但我找不到代码的任何问题:
$mapCode = "<script src=\"http://maps.google.com/maps?file=api&v=2&sensor=false&key=$google_maps_apiKey\" type=\"text/javascript\"></script>
<div id=\"map_canvas\" style=\"width: 500px; height: 500px\"></div>
<script type=\"text/javascript\">
function showAddress(address) {
var map = new GMap2(document.getElementById('map_canvas'));
alert(\" not found\");
var geocoder = new GClientGeocoder();
geocoder.getLatLng(
address,
function(point) {
if (!point) {
alert(address + \" not found\");
} else {
map.setCenter(point, 13);
var marker = new GMarker(point);
map.addOverlay(marker);
}
}
);
}
showAddress(\"$address\");
</script>";
echo $mapCode;
非常感谢任何帮助。谢谢
I have the following code in my webpage - the map div is not showing the google map but I can't find anything wrong with the code:
$mapCode = "<script src=\"http://maps.google.com/maps?file=api&v=2&sensor=false&key=$google_maps_apiKey\" type=\"text/javascript\"></script>
<div id=\"map_canvas\" style=\"width: 500px; height: 500px\"></div>
<script type=\"text/javascript\">
function showAddress(address) {
var map = new GMap2(document.getElementById('map_canvas'));
alert(\" not found\");
var geocoder = new GClientGeocoder();
geocoder.getLatLng(
address,
function(point) {
if (!point) {
alert(address + \" not found\");
} else {
map.setCenter(point, 13);
var marker = new GMarker(point);
map.addOverlay(marker);
}
}
);
}
showAddress(\"$address\");
</script>";
echo $mapCode;
Any help is much appreciated. Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我只是通过物理告诉它高度来让它工作......在我的CSS中我输入:
而
不是不知道为什么它最初不起作用......
I just got it to work by physically telling it a height.... in my css I put:
instead of
don't know why it didn't originally work...