2

我有一张使用 ngmap 的地图。通过一个表格,我得到一个数据集并在地图中表示。当我请求一个新数据集时,地图会显示标记而不是线。这是我的代码的一部分。

JS:

var app = angular.module('dataview', ['ngMap', 'ngSanitize'])

app.controller('DataViewCtrl', function($scope, $http)
{
  $scope.makemap = function()
    {
     $scope.polyline = [];

     $scope.graph_data.map(function(item)
      {    
      var gpsarr = [item['latitude'], item['longitude'], 'http://maps.gstatic.com/intl/en_us/mapfiles/markers2/measle_blue.png', new Date(item[0])];
                       
$scope.polyline.push(gpsarr);
     }
          
$scope.polyline[0][2]='http://maps.google.com/mapfiles/ms/icons/green-dot.png';
$scope.polyline[$scope.polyline.length-1][2]='http://maps.google.com/mapfiles/ms/icons/red-dot.png';
   }          
});

HTML:

<map center="{{polyline[0][0]}},{{polyline[0][1]}}" zoom="15" style="width:100%; height: 500px;">
  <marker ng-repeat="pos in polyline" position="{{pos[0]}}, {{pos[1]}}" icon="{{pos[2]}}" title="{{(pos[3] | date:'EEE, MM-dd-yyyy HH:mm:ss:sss')}}">
  </marker>  
  <shape name="polyline" path="{{polyline}}" geodesic="true" stroke-color="#0000FF", stroke-opacity="1.0" stroke-weight="3"></shape>
</map>  

第一次结果正确(查看标记和线)

在此处输入图像描述

第二次结果不正确(显示新标记但不显示新行)

在此处输入图像描述

4

0 回答 0