我正在尝试使用 angularjs 和我找到的用于实例化 GMaps 的指令开发一个应用程序: http ://nlaplante.github.io/angular-google-maps/#!/usage。我按照所有步骤操作,但无法渲染地图!它没有返回任何错误!
在 HTML 中
<html ng-app="Maptesting">
<div ng-view></div>
<script src="app/map.js">
</script>
在控制器中:
angular.module('Maptesting', ['google-maps'])
.controller('CtrlGMap', ['$scope', function($scope) {
$scope.center = {
latitude: 45,
longitude: -73
};
$scope.markers = [];
$scope.zoom = 8;
}])
原文由 Facu Ferrari 发布,翻译遵循 CC BY-SA 4.0 许可协议
不同的答案,但我觉得 google-maps-directive 对我来说更难使用。因此,我为自己的项目创建了一个名为 ng-map 的 google maps angularjs 指令。这不需要任何 Javascript 编码来实现简单的功能。
看起来像这样