Google地图不会与domainname.com一起显示 [英] Google Maps are not showing with domainname.com

查看:408
本文介绍了Google地图不会与domainname.com一起显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



 < script async defer src =https:// maps。 googleapis.com/maps/api/js?key=mykey\"type=\"text/javascript\"></script> 

JavaScript功能

 < script type =text / javascript> 
var geocoder;
var map;
var latlng;

函数codeAddress(address){
geocoder = new google.maps.Geocoder();
if(geocoder){
geocoder.geocode({'address':address},function(results,status){
if(status == google.maps.GeocoderStatus.OK){
latlng = results [0] .geometry.location;
latlng = new google.maps.LatLng(latlng);
var myOptions = {
zoom:13,
中心:latlng,
mapTypeId:google.maps.MapTypeId.ROADMAP
;;
var map = new google.maps.Map(document.getElementById(map_canvas),myOptions);
map.setCenter(results [0] .geometry.location);
var marker = new google.maps.Marker({
map:map,
position:results [0 ] .geometry.location
});

} else {
alert(Geocode不成功,原因如下:+ status);
}
});
}
}
< / script>

我读下面的问题,但是我的问题没有解决。



为什么它不显示没有 www

的地图

解决方案 c。*。comprettainsurance.com / * 不符合 http :// comprettains urance.com/contactus (它与comprettainsurance.com的任何子域名相匹配,但不包含域本身)。



您需要添加一个额外的引用线:

  comprettainsurance。 com / * 


JavaScript:

<script async defer src="https://maps.googleapis.com/maps/api/js?key=mykey"type="text/javascript"></script>

JavaScript Function:

<script type="text/javascript">
  var geocoder;
  var map;
  var latlng;

  function codeAddress(address) {
    geocoder = new google.maps.Geocoder();
    if (geocoder) {
      geocoder.geocode( { 'address': address}, function(results, status) {
        if (status == google.maps.GeocoderStatus.OK) {
            latlng=results[0].geometry.location;
            latlng = new google.maps.LatLng(latlng);
            var myOptions = {
              zoom: 13,
              center: latlng,
              mapTypeId: google.maps.MapTypeId.ROADMAP
            };
            var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
                  map.setCenter(results[0].geometry.location);
                  var marker = new google.maps.Marker({
                      map: map, 
                      position: results[0].geometry.location
              });

        } else {
          alert("Geocode was not successful for the following reason: " + status);
        }
      });
    }
  }
</script>

I reads following questions but my problem is not solved.

Google Maps JavaScript API RefererNotAllowedMapError

Google maps API referrer not allowed

Google Maps API error: Google Maps API error: RefererNotAllowedMapError

The problem is , when i open my website like this.

http://mysiste.com/contactus

it is not showing map and showing following error.

Google Maps API error: RefererNotAllowedMapError https://developers.google.com/maps/documentation/javascript/error-messages#referer-not-allowed-map-error Your site URL to be authorized: http://comprettainsurance.com/contactus"

while if i open my site like this.

http://www.mysiste.com/contactus

the maps are working perfectly.

My Credential Page where i add domain like this.

so why it is not showing maps without www?

解决方案

*.comprettainsurance.com/* does not match http://comprettainsurance.com/contactus (it matches any subdomain of comprettainsurance.com, but not the domain itself).

You need to add an additional referrer line:

comprettainsurance.com/*

这篇关于Google地图不会与domainname.com一起显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆