Ng map 标记信息窗口未使用ngMap工作

Ng map 标记信息窗口未使用ngMap工作,ng-map,javascript,angularjs,angularjs-ng-repeat,google-maps-markers,Ng Map,Javascript,Angularjs,Angularjs Ng Repeat,Google Maps Markers,我正试图用谷歌地图显示一个信息窗口。这是我的密码: <div id="map"> <ng-map zoom="13" center="[{{latitude}}, {{longitude}}]" style="display: block; height: 100%;"> <marker ng-repeat="pothole in potholeData" position="{{pothole.lat}},{{pothole.lng}}" on-cli

我正试图用谷歌地图显示一个信息窗口。这是我的密码:

<div id="map">
  <ng-map zoom="13" center="[{{latitude}}, {{longitude}}]" style="display: block; height: 100%;">
    <marker ng-repeat="pothole in potholeData" position="{{pothole.lat}},{{pothole.lng}}" on-click="showDetails(e, pothole)"></marker>
  </ng-map>
</div>
在showDetails函数中,我得到了未定义的凹坑。 有人能帮我吗?

问题出在单击时=显示详细信息,坑洞,更改为单击时=显示详细信息,坑洞。 我已经制作了代码片段

角度。模块'mapApp',['ngMap'] .controller'mapController',函数$scope,NgMap{ NgMap.getMap.thenfunctionmap{ $scope.map=map; }; $scope.potholeData=[ {lat:59.923043,lng:10.752839}, {lat:59.339025,lng:18.065818}, {lat:55.675507,lng:12.574227}, {lat:52.521248,lng:13.399038}, {拉丁美洲:48.856127,液化天然气:2.346525} ]; $scope.showDetails=函数,凹坑{ 控制台。凹坑; var infowindow=new google.maps.infowindow; var center=new google.maps.LatLngpothole.lat,pothore.lng; infowindow.setContent +pothore.lat++pothore.lng+; infowindow.setPositioncenter; 打开$scope.map; }; };
根据@artgb answer,您需要将单击时=显示详细信息,凹坑更改为单击时=显示详细信息,凹坑。请参见事件参数。这才是真正的问题

在这个完整版本中,工作方式是相同的

根据

您需要以下脚本:

. AIzaSyCGsmJhDsK9HS2_KYTQXBIJQAE2AT_Pw0是本演示的API密钥。您可以在:。 您需要使用id标识标记。当您使用ngRepeat时,我使用以下数据:

该指令包含用户的原始Google Maps V3 api,因此您不需要使用新的Google.Maps对象。 大概是这样的:

作用{ angular.moduleapp[ngMap].controllerController,[$scope,ngMap,函数$scope,ngMap{ NgMap.getMap.thenfunctionmap{ $scope.map=map; }; $scope.latitude=-12.339223; $scope.longitude=-76.808624; $scope.potholeData=[{ id:位置1, 正文:部分内容1。。。, 纬度:-12.339223, 液化天然气:-76.808624 }, { id:位置2, 正文:部分内容2。。。, lat:-12.349423, 液化天然气:-76.828824 }]; $scope.pothore={}; $scope.showDetails=函数,凹坑{ $scope.pothore=坑洞; $scope.map.showInfoWindow'foo-iw',pothore.id; }; $scope.hideDetail=函数{ $scope.map.hideInfo窗口'foo-iw'; }; }]; }; id:{{pothore.id}}文本:{{pothore.Text}位置:{{anchor.getPosition}
嘿,我有完全相同的密码。我已经包括了所有的脚本。我不在我去的地方wrong@chan您需要将单击时=显示详细信息,凹坑更改为单击时=显示详细信息,凹坑。请参见事件参数。这才是真正的问题。@artgb谢谢你的回答。我只有一个问题。如何将样式添加到该信息窗口?
$scope.showDetails = function(e, pothole) {
  var infowindow = new google.maps.InfoWindow();
  var center = new google.maps.LatLng(pothole.lat, pothole.lng);

  infowindow.setContent(
    '<h3>' + pothole + '</h3>');

  infowindow.setPosition(center);
  infowindow.open($scope.map);
}
[{
  "id": "Location1",
  "text": "Some content 1...",
  "lat": -12.339223,
  "lng": -76.808624
}, {
  "id": "Location2",
  "text": "Some content 2...",
  "lat": -12.349423,
  "lng": -76.828824
}]