让我知道这是否有效。我改变了一些地图逻辑
for
循环并移除
createMarker
for (i = 0; i < $scope.allPropertyList.length; i++) {
var latitude = parseFloat($scope.allPropertyList[i]['property_latitude']);
var longitude = parseFloat($scope.allPropertyList[i]['property_longitude']);
var property_address = $scope.allPropertyList[i]['property_address'];
var marker = new google.maps.Marker({
position: new google.maps.LatLng(latitude , longitude),
map: $scope.map
});
var contentString = '<h1 style="font-size: 18px">' + property_address + '</h1>'
+'<div>'
+'<a id="selectFromMapButton" ng-click="testPrint()" class="c-btn" style="color: white">Select Property</a>'
+'</div>';
var compiledContent = $compile(contentString)($scope)
var infowindow = new google.maps.InfoWindow({
content: ''
});
google.maps.event.addListener(marker, 'click', (function(marker, contentString, scope, infowindow) {
return function() {
infowindow.setContent(contentString);
infowindow.open(scope.map, marker);
};
})(marker, compiledContent[0], $scope, infowindow));
}