我正在尝试在我的应用中使用谷歌地图的api作为位置选择器。通过访问此网址
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true&libraries=places&language=en-US"></script>
虽然这在本地解决方案中有效但它在我的主应用程序中无效。它正在发出错误
ReferenceError: google is not defined angular.js:13294
at HTMLDocument.<anonymous> (VM6558 locator.js:87)
at fire (jquery.js:3187)
at Object.self.add [as done] (jquery.js:3246)
at jQuery.fn.ready (jquery.js:3496)
at Object.<anonymous> (VM6558 locator.js:86)
at Object.invoke (angular.js:4625)
at Object.enforcedReturnValue [as $get] (angular.js:4464)
at Object.invoke (angular.js:4625)
at angular.js:4424
脚本顺序
<link rel="stylesheet" href="libs/bootstrap/dist/css/bootstrap.min.css"/>
<script type="text/javascript" src="libs/jquery/dist/jquery.min.js"> </script>
<script type="text/javascript" src="libs/jquery-ui/jquery-ui.min.js"></script>
<link rel="stylesheet" href="/public/libs/jquery-ui/themes/smoothness/jquery-ui.css">
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true&libraries=places&language=en-US"></script>
<script src="libs/angular/angular.js"></script>
<script src="libs/angular-route/angular-route.js"></script>
<script src="libs/angular-animate/angular-animate.js"></script>
答案 0 :(得分:0)
vm.initialize = function(){
var mapOptions = {
zoom: 14,
center: new google.maps.LatLng(10.772573, 106.698000)
}
map = new google.maps.Map(document.getElementById('order-detail-map'), mapOptions);
latlng = new google.maps.LatLng(vm.order.customer.address.position.lat, vm.order.customer.address.position.long);
setTimeout(function(){
google.maps.event.trigger(map, 'resize');
map.setCenter(latlng);
}, 50);
myMarker = new google.maps.Marker({
draggable: false,
animation: google.maps.Animation.DROP,
icon: "i/marker.png",
position:latlng
});
myMarker.setMap(map);
}
google.maps.event.addDomListener(window, 'load', vm.initialize());
&#13;