0
我使用谷歌地圖,但標記重疊,如果相同的位置來到數據庫,我該如何解決這個問題。我在運行時獲取數據。我正在使用angularjs,請幫忙...?谷歌地圖上使用angularjs重疊標記
這是我的html頁面: -
</custom-marker>
<info-window id="foo-iw">
<div ng-non-bindable="">
<div style=" border-style: solid;border-color:black;margin-top:4px;background-color:#DEDBDA";width:100%;>
<div style="margin : 7px;color: black;background-color:#DEDBDA;width:96%;">
<b>Serial No :</b> {{vm.pump.serialNo}}<br/>
<b>Customer :</b> {{vm.pump.customer}}<br/>
<b>Protocol :</b> {{vm.pump.protocol}}<br/>
<b>Location :</b> {{vm.pump.address}}<br/>
<b>Last Access Time :</b> {{vm.pump.lastAccessTime | date:'d MMM, y hh:mm:ss a'}}<br/>
<b>Malfunction :</b> {{vm.pump.pumpInfo.malfunction}} <b>:</b>
{{errorData.malfunction[0][vm.pump.pumpInfo.malfunction]}}<br/>
<b>Warning :</b> {{vm.pump.pumpInfo.warning}} <b>:</b>
{{errorData.warning[0][vm.pump.pumpInfo.warning]}}<br/>
<b>Alarm :</b> {{vm.pump.pumpInfo.alarm}} <b>:</b>
{{errorData.alarm[0][vm.pump.pumpInfo.alarm]}}
<!-- {{errorData}} -->
</div>
</div>
</div>
</info-window>
</ng-map>
這是我的js文件: -
$scope.pumpMap = function(data){
$scope.pumpError();
var i=0;var mapData={};
for(i=0;i<data.ScannedCount;i++){
if(data.Items[i].hasOwnProperty("isActive")){
mapData[i] ={position:[data.Items[i].pumpdetail.location.latitude, data.Items[i].pumpdetail.location.longitude],
serialNo:data.Items[i].serialno, isActive:data.Items[i].isActive,
lastAccessTime: data.Items[i].lastupdated, pumpInfo: data.Items[i].pumpdetail.results[0].pump_info,
address: data.Items[i].pumpaddress, customer: data.Items[i].company, protocol: data.Items[i].protocol};
}
}
NgMap.getMap().then(function(map) {
console.log('map', map);
$scope.vm.map = map;
});
$scope.vm.pumps = mapData;
$scope.vm.pump = $scope.vm.pumps[0];
$scope.vm.showDetail = function(e, pump) {
$scope.vm.pump = pump;
$scope.vm.map.showInfoWindow('foo-iw', pump.serialNo);
};
$scope.vm.hideDetail = function() {
$scope.vm.map.hideInfoWindow('foo-iw');
};
$scope.vm.currentIndex = 0;
$scope.vm.selectNextCustomMarker = function() {
$scope.vm.map.customMarkers[$scope.vm.currentIndex].removeClass('selected');
$scope.vm.currentIndex = ($scope.vm.currentIndex+1) % $scope.vm.pumps.length;
$scope.vm.map.customMarkers[$scope.vm.currentIndex].addClass('selected');
$scope.vm.currentPosition = $scope.vm.pumps[$scope.vm.currentIndex];
}
};