高德地图无网络链接 显示 暂不支持地图查看

<div class="pad" style="height: 450px;" id="test"></div>
let boolean = new Boolean();
$.ajax({
    url: 'https://webapi.amap.com/maps?v=1.4.15&key=您申请的key值',
    success: function(result){
        boolean = true;
    },
    error: function(result){
        alert("无网络链接,暂不支持地图查看!");
        boolean = false;
        $("#servermap").attr("class","hidden");
    }
});
if (boolean) {
    document.getElementById("test").innerHTML = '<object type="text/html" data="GaodeMap.html" width="100%" height="100%"></object>';
}

这样加载可能会有卡顿又修改了下,这样会在ajax响应的时候出现正在加载地图css

$.ajax({
    timeout: 1500,
    url: 'https://webapi.amap.com/maps?v=1.4.15&key=您申请的key值',
    success: function(result){
        document.getElementById("test").innerHTML = '<object type="text/html" data="GaodeMap.html" width="100%" height="100%"></object>';
    },
    beforeSend: function(){
        $("#test").css("text-align","center");
        $('#test').html('正在加载地图,请稍等。。。。');
    },
    error: function(result){
        $("#test").attr("style","height: 100px");
        document.getElementById("test").innerHTML = '<center>无网络链接,暂不支持地图查看</center>';
    }
});

具体的html地图文件高德地图api能够本身画html

相关文章
相关标签/搜索