-1

我在这里有一个网站:www.hosting6280514.az.pl/ 使用 SSL ...我尝试在该页面上显示谷歌地图,但只显示控件、标记和地图/卫星开关,实际地图不是. 这是我正在使用的代码:

<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
    <style>
      html, body, #map-canvas {
        margin: 0;
        padding: 0;
        height: 100%;
      }
    </style>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
<script>
var map;
function refreshing() {
    setTimeout("location.reload(true);",5000);
}








function initialize()
{
var position = new google.maps.LatLng(<?php echo$lat; ?>,<?php echo$lgt; ?>);
    var mapOptions = 
    {
    zoom: 18,
    center: position,
    mapTypeId: google.maps.MapTypeId.ROADMAP
    };
map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);

/*var image = new google.maps.MarkerImage('http://hosting6280514.az.pl/pawel/images/car.png',
    // This marker is 129 pixels wide by 42 pixels tall.
    new google.maps.Size(129, 42),
    // The origin for this image is 0,0.
    new google.maps.Point(0,0),
    // The anchor for this image is the base of the flagpole at 18,42.
    new google.maps.Point(18, 42)
);*/



var marker = new google.maps.Marker(
    {
        position: position,                         // its position is where position variable points
        title: "Car's position"
        //icon: image
    });

marker.setMap(map);                                 // To add the marker to the map, call setMap();
}



google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body onload="JavaScript:refreshing();">
<div id="map-canvas"></div>
</body>
</html>

抱歉,问题是:有人知道为什么地图不显示吗​​?

4

1 回答 1

0

为了更新地图上的位置,请尝试沿着这些路线进行一些操作。geolocation.watchPosition如果您想获得当前位置,也可以使用。

var position, marker;

function updateLocation() {
    $.ajax({
        url: '/something.php',
        dataType: 'JSON',
        success: function(data) {
            position = new google.maps.LatLng(data.lat, data.lng);
            marker.setPosition(position);
        }
    });
}



function initialize() {
    position = // same as you have it

    // ...

    marker = // same as you have it
}
于 2013-08-09T18:54:15.350 回答