2016-03-20 15 views
1

私は、角度の表示に埋め込まれたGoogleマップを持っています(下の図のように表示されます)。ページを更新。角度表示でGoogleマップを表示する断続的な問題

enter image description here

Googleに言及は、このようなページの先頭にあります。

<script src="https://maps.google.com/maps/api/js?key=<api_key>" type="text/javascript"></script> 

(角ビューで)私のHTMLは、次のようになります。

 <div id="map_canvas" style="width: 100%; height: 300px"></div> 

私のコードビューのコントローラでは、次のようになります。

var geocoder = new google.maps.Geocoder(); 
geocoder.geocode({ 'address': addressLine }, function (results, status) { 

    if (status == google.maps.GeocoderStatus.OK) { 
      var myLatLng = { lat: results[0].geometry.location.lat(), 
          lng: results[0].geometry.location.lng() }; 

    var myOptions = { zoom: 8, center: myLatLng }; 
    var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); 

    var marker = new google.maps.Marker({ 
      position: myLatLng, 
      map: map, 
      title: name 
      }); 
    } 
}); 

これはなぜ起こるのか誰にも分かりますか?それともこれまで経験したことがありますか?

ありがとうございます!

答えて

1

Googleマップのディレクティブを作成します。状態のコントローラは、ビューがロードされる前に実行されます。ディレクティブのコントローラーがビューの後にロードされます。

多くのGoogleマップディレクティブが存在します。だからすでに存在するものを見つけてそれを微調整してください。例えば、http://angular-ui.github.io/angular-google-maps/#!/

関連する問題