2016-11-22 5 views
-2

私は、ユーザの所在地を取得して表示する必要があるウェブサイトを開発しています。 はしかし、私はプロジェクトを実行するたびに、このエラーメッセージが表示されます。 enter image description hereユーザの所在地を取得して表示するウェブサイト

これは私のコードです:私は間違って何をやっています

<!DOCTYPE html> 

<html xmlns="http://www.w3.org/1999/xhtml"> 
<head runat="server"> 
    <title></title> 
</head> 
<body> 
    <form id="form1" runat="server"> 
    <div> 
     <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script> 
<script type="text/javascript"> 
if (navigator.geolocation) { 
    navigator.geolocation.getCurrentPosition(function (p) { 
     var LatLng = new google.maps.LatLng(p.coords.latitude, p.coords.longitude); 
     var mapOptions = { 
      center: LatLng, 
      zoom: 13, 
      mapTypeId: google.maps.MapTypeId.ROADMAP 
     }; 
     var map = new google.maps.Map(document.getElementById("dvMap"), mapOptions); 
     var marker = new google.maps.Marker({ 
      position: LatLng, 
      map: map, 
      title: "<div style = 'height:60px;width:200px'><b>Your location:</b><br />Latitude: " + p.coords.latitude + "<br />Longitude: " + p.coords.longitude 
     }); 
     google.maps.event.addListener(marker, "click", function (e) { 
      var infoWindow = new google.maps.InfoWindow(); 
      infoWindow.setContent(marker.title); 
      infoWindow.open(map, marker); 
     }); 
    }); 
} else { 
    alert('Geo Location feature is not supported in this browser.'); 
} 
</script> 
<div id="dvMap" style="width: 500px; height: 500px"> 
</div> 
    </div> 
    </form> 
</body> 
</html> 

??? 誰も助けてもらえますか?

+1

を、あなたの写真は、同じメッセージ – Webruster

+0

を示しているが、そのための解決策は何ですか?それは私に現在の場所の地図を示していますが、おそらく2秒未満でそのようなエラーメッセージが表示されます – user3599431

答えて

0

私は私の問題を解決しました! はIちょうど私のAPIキーを追加するコード行を追加:あなたのコンソールをuを伝えようとしているもの

<script src="//maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&key=MY_KEY" async="" defer="defer" type="text/javascript"></script> 
+0

APIキーを投稿しないで、秘密にしてください – Webruster

+0

注釈をありがとう!私は完全に忘れてしまった! – user3599431

関連する問題