Javascript Angularjs和谷歌地图API
我在AngularJS中有一个谷歌地图,我正在尝试为每个ng重复创建一个方向的标记(从a到B的一条线)。这是我的HTMLJavascript Angularjs和谷歌地图API,javascript,angularjs,google-maps,google-maps-api-3,Javascript,Angularjs,Google Maps,Google Maps Api 3,我在AngularJS中有一个谷歌地图,我正在尝试为每个ng重复创建一个方向的标记(从a到B的一条线)。这是我的HTML <div class="col-lg-12" ng-repeat="quotes in quotes"> <div class="ibox float-e-margins"> <div class="ibox-title"> <span class="label
<div class="col-lg-12" ng-repeat="quotes in quotes">
<div class="ibox float-e-margins">
<div class="ibox-title">
<span class="label label-success pull-right">{{formatDte(quotes.date)}}</span>
<h5>{{quotes.name}}</h5>
</div>
<div class="ibox-content">
<h1>{{quotes.pnum}}</h1>
<p>{{quotes.pcodefrom}} to {{quotes.pcodeto}}</p>
<small>Reg : {{quotes.Reg}}</small>
<br/>
<small>Notes : {{quotes.notes}}</small>
<div class="row">
<div class="col-md-12">
<div class="ibox ">
<div class="ibox-content">
<section id="map" ng-controller="GoogleMaps">
<div ui-map="myMap" ui-options="mapOptions" class="google-map"></div>
</section>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
我看过不同的角度项目,但我尝试的所有东西都没有显示地图,请有人帮助我将简单代码嵌入,这样我就可以向ng repeat中的一个函数发送2个地址或邮政编码,地图将显示路线,而不是静态地图
谢谢您可以尝试使用ngMap。我们已经在我们的项目中使用了它。为我们工作很好 参考链接: 在控制器中:您可以使用NgMap服务实例化map实例: 在Html中:这里我得到了一个组织列表,我们可以在
标记上使用ng repeat来区分标记,我们可以动态地为标记分配id:
<ng-map default-style="false" id="map" center="current-position" zoom="12" style="height:550px;width:100%;">
<marker ng-repeat="org in orgList" id="id_{{org.organizationLocationAddressId}}" position="{{org.location}}" on-click="selectOrg(org)" on-mouseover="showDetails(org)" on-mouseout="hideDetail()" draggable="{{org.isDraggable}}" on-dragend="changeLocation($event)" on-position-changed="getMarkerPosition()" icon="{{org.organizationLocationId == selectedId?iconsList.SELECTED_ICONS[org.organizationTypeIconsEnum]:org.organizationTypeIcon}}"></marker>
</ng-map>
您在浏览器控制台中看到任何具体错误吗?没有,地图工作只是想知道如何添加路由。我添加了JS文件,它说NgMap没有定义,也没有显示任何内容。您需要在声明模块时插入NgMap模块,还需要在控制器中插入NgMap服务。
NgMap.getMap().then(function (map) {
$scope.map = map;
});
<ng-map default-style="false" id="map" center="current-position" zoom="12" style="height:550px;width:100%;">
<marker ng-repeat="org in orgList" id="id_{{org.organizationLocationAddressId}}" position="{{org.location}}" on-click="selectOrg(org)" on-mouseover="showDetails(org)" on-mouseout="hideDetail()" draggable="{{org.isDraggable}}" on-dragend="changeLocation($event)" on-position-changed="getMarkerPosition()" icon="{{org.organizationLocationId == selectedId?iconsList.SELECTED_ICONS[org.organizationTypeIconsEnum]:org.organizationTypeIcon}}"></marker>
</ng-map>