【问题标题】:This page can't load Google Maps properly此页面无法正确加载 Google 地图
【发布时间】:2019-12-23 23:13:21
【问题描述】:

我正在尝试从地图中获取纬度和经度,但出现此错误:

此页面无法正确加载 Google 地图。

我不确定导致此错误的原因。 我需要添加一个键还是它只是我的代码中的一个错误?

感谢任何帮助。

我的代码

<script type="text/javascript">

    $("#selectLocation").hide();
    $(document).on("click",".setSelectLocation",function() {
        $(".setSelectLocation").hide();
        $("#selectLocation").show();
    });

    $("#area_id option").hide();
    $("#area_id option[data-parent=" + $('#country').val() + "]").show();
    $(document).on("change","#country",function() {
        var value = $(this).val();
        $("#area_id").show();
        $("#area_id option").hide();
        $('#area_id').prepend('<option disabled selected value="#">أختر المحافظه</option>');
        $("#area_id option[data-parent=" + value + "]").show();
    });

    function initialize() {
        var e = new google.maps.LatLng(24.701925,46.675415), t = {
            zoom: 5,
            center: e,
            panControl: !0,
            scrollwheel: 1,
            scaleControl: !0,
            overviewMapControl: !0,
            overviewMapControlOptions: {opened: !0},
            mapTypeId: google.maps.MapTypeId.terrain
        };
        map = new google.maps.Map(document.getElementById("latlongmap"), t)
        geocoder = new google.maps.Geocoder
        marker = new google.maps.Marker({
            position: e,
            map: map
        })
        map.streetViewControl = false
        infowindow = new google.maps.InfoWindow({
            content: "(24.701925,46.675415))"
        })
        google.maps.event.addListener(map, "click", function (e) {
            marker.setPosition(e.latLng);
            var t = e.latLng
            o = "(" + t.lat().toFixed(6) + ", " + t.lng().toFixed(6) + ")";
            infowindow.setContent(o),
            document.getElementById("lat").value = t.lat().toFixed(6),
            document.getElementById("lng").value = t.lng().toFixed(6)
        })
    }

</script>
<script src="https://maps.googleapis.com/maps/api/js?key=KEY&language=ar&callback=initialize"></script>

【问题讨论】:

  • 这个错误可能是因为额外的括号吗? content: "(24.701925,46.675415) ) "
  • 对我来说,initialize() 功能正常工作并显示地图。请显示 selectLocationarea_id 元素的 HTML,以便我可以调试其余代码。

标签: javascript laravel google-maps


【解决方案1】:

对于在加载带有“仅用于开发目的”水印的谷歌地图时遇到“此页面无法正确加载谷歌地图”错误的任何人留言:

有问题的错误是这个:https://developers.google.com/maps/faq#api-key-billing-errors

为了使用 Google Maps Platform 产品,必须进行结算 已在您的帐户上启用,并且所有请求都必须包含有效的 API 键

希望这会有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-12-28
    • 1970-01-01
    • 2020-06-23
    • 1970-01-01
    • 1970-01-01
    • 2021-07-10
    • 2014-08-15
    • 1970-01-01
    相关资源
    最近更新 更多