0

私はGoogleマーカーマネージャーを作成しようとしていますが、エラーメッセージマーカーを取得しようとしていません、iveは問題の原因となっているコードをコメントアウトしました。マーカーは、私はこの自動的にGoogleマーカーのMANAGERGoogleマーカーマネージャーが定義されていません

を使用して、Googleマップ上に表示される操作を行うことができるようにしたい
@{ 
    ViewBag.Title = "Index"; 
} 

<h2>Index</h2> 

<div id="map_canvas" style="width:500px; height:500px;"></div> 

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"> 

</script> 


    <script type="text/javascript"> 

     var map; 
     var counter; 
     var latlng; 
     var locationAddress; 
     var geocoder; 
     function initialize() { 
      geocoder = new google.maps.Geocoder(); 
      latlng = new google.maps.LatLng(46.043830, 14.488864); 
      var myOptions = { 
       zoom: 16, 
       center: latlng, 
       mapTypeId: google.maps.MapTypeId.ROADMAP 
      }; 
      map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); 
      counter = 0; 

      google.maps.event.addListener(map, 'click', function (event) { 
       map.setCenter(event.latlng); 
       placeMarker(event.latLng); 

      }); 


     } 

     function placeMarker(location) { 
      var clickedLocation = new google.maps.LatLng(location); 
      latlng = location; 
      var marker = new google.maps.Marker({ 
       position: location, 
       map: map 
      }); 
      codeLatLng(location, marker); 
     } 

     function addLocationInfo(marker) { 
      var infoWindow = new google.maps.InfoWindow({ content: locationAddress, size: new google.maps.Size(50, 50) }); 
      google.maps.event.addListener(marker, 'click', function() { 
       infoWindow.open(map, marker); 
      }); 
     } 

     function codeLatLng(latlng, marker) { 
      if (geocoder) { 
       geocoder.geocode({ 'latLng': latlng }, function (results, status) { 
        if (status == google.maps.GeocoderStatus.OK) { 
         if (results[1]) { 
          locationAddress = results[1].formatted_address; 
         } 
        } else { 
         locationAddress = "Neznan naslov"; 
        } 
        addLocationInfo(marker); 
       }); 
      } 
     } 

//  // Create a new instance of the MarkerManager 
//  var mgr = new MarkerManager(map); 
//  // Create marker array 
//  var markers = []; 
//  // Loop to create markers and adding them to the MarkerManager 
//  for (var i = 0; i < 50; i += 0.1) { 
//   var marker = new GMarker(new GLatLng(59.0 + i, 13.80 + i)); 
//   markers.push(marker); 
//  } 
//  // Add the array to the MarkerManager 
//  mgr.addMarkers(markers); 
//  // Refresh the MarkerManager to make the markers appear on the map 
//  mgr.refresh(); 

     $(document).ready(function() { 
      initialize(); 
     }); 

    </script> 

エラーメッセージ: MarkerManagerは

答えて

2

あなたはGoogle MapsのAPIを混合しているが定義されていません。 2およびAPI 3コード。
v = 2パラメータを削除するか、v = 3(またはv = 3.5など)に変更します。この

変更: センサー= trueまたはセンサー= falseを

のいずれかに センサー= truese APIキーを削除し、そのだけ

は全てGMap2の、GLatLngを取り除くAPI 2.のために必須ですAPI 2用のコードのタイプを変更し、すべてをAPI 3構文に変更します。

+0

私はコードを更新しました。私は今、新しい問題を抱えています。混乱して申し訳ありません。私はあなたの解決策を説明し、何が起こるかを見て、APIコードを混ぜる愚かなことを見ます。 – MJCoder

+0

まだ問題を引き起こしているあなたの方法を試して、私は私の最初の投稿でやったコード改正に固執し、誰かが助けることができる/私を案内するまで待つ – MJCoder

+0

あなたの方法はまだAPIと互換性のないAPI 2コードを使用しています3. Marker Managerが必要とするJSファイルを呼び出していますか? – duncan

関連する問題