[英]Google Map not showing up
I need to implement on my php page map. 我需要在我的php页面地图上实现。 I have container <div id="map"></div>
which is inside other div, and I put this code inside <head>
tag but it doesn't show at all. 我有容器<div id="map"></div>
,它位于其他div中,我将此代码放在<head>
标记内,但它根本不显示。 Can anybody help me? 有谁能够帮助我?
<script type="text/javascript" src="javascript/jquery-1.4.3.js"></script>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
(function() {
window.onload = function() {
var mapDiv = document.getElementById('map');
var latlng = new google.maps.LatLng(37.09, -95.71);
var options = {
center: latlng,
zoom: 4,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(mapDiv, options);
}
})();
</script>
Did you specify size for your div? 你有没有为你的div指定大小? eg: 例如:
<div id="map" style="width: 300px; height: 300px;"></div>
If this doesn't work you might have to post a snippet of your HTML and CSS.. 如果这不起作用,您可能需要发布HTML和CSS的片段。
I had some thing like that happen and all I had to do was use jquery compliance code. 我有类似的事情发生,我所要做的就是使用jquery合规性代码。 jQuery(document).ready(function($) { $(function() { // Your map code here. }); }); jQuery(document).ready(function($){$(function(){//这里的地图代码。});});
Your code does work for me even though the last line, when you close that anonymous function, gave me an error like you were using some illegal character, so I had to retype it. 你的代码对我有用,即使最后一行,当你关闭匿名函数时,给了我一个错误,就像你使用了一些非法字符一样,所以我不得不重新输入它。 Once I did, it worked perfectly showing a road map of all of the United States. 有一次,它完美地显示了所有美国的路线图。 Other than that possible illegal character you could also try: 除了可能的非法角色,您还可以尝试:
Hope that helps. 希望有所帮助。
If any one using google map code from javascript or jquery or any language, He/She should use for local host https://localhost/test/ or in server https://example.com . 如果任何人使用来自javascript或jquery或任何语言的谷歌地图代码,他/她应该使用本地主机https:// localhost / test /或服务器https://example.com 。
Means use secure url like https 意味着像https一样使用安全网址
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.