AngularJS传单存储点

时间:2018-11-01 03:33:29

标签: javascript angularjs

我目前有一个ng-repeat可以让用户显示点,但是我不知道如何将其存储在一个地方,以便用户可以显示和删除多个点。现在可以显示多个点,但是我不知道如何将点1删除1。

看起来如何

enter image description here

因此,当用户单击地图上的所有3个“视图”时,它将显示该点。 (当前正在工作)但是我将它们全部存储在一层中,我喜欢如何将它们分成不同的层,以便用户可以删除各个点?

JS:

        $scope.getMapData = function (msg, passedIndex) {
                map.addLayer(cities);

                $scope.Lng.length = 0;
                $scope.Lat.length = 0;
                $scope.dataLatLng.length = 0;

               queryNameUrl = 'https://developers.onemap.sg/publicapi/themeapi/retrieveTheme?queryName=' + msg +
               '&token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjMsInVzZXJfaWQiOjMsImVtYWlsIjoicHVibGljQXBpUm9sZUBzbGEuZ292LnNnIiwiZm9yZXZlciI6ZmFsc2UsImlzcyI6Imh0dHA6XC9cL29tMi5kZmUub25lbWFwLnNnXC9hcGlcL3YyXC91c2VyXC9zZXNzaW9uIiwiaWF0IjoxNTQwOTI5OTE2LCJleHAiOjE1NDEzNjE5MTYsIm5iZiI6MTU0MDkyOTkxNiwianRpIjoiYjVkNmZkNGJhOWJiNGJiM2FkNWQzN2ZhNTAzMGIxYWEifQ.YQdfV43wrg8dX-He7-mwIL2Qhjsexq0tgNu5RotAdu4';
               $http.get(queryNameUrl).then(function(response) {
                 $scope.apiResult = response.data.SrchResults;
                 $scope.apiResult.splice(0,1);
                 $scope.cnmoh = true;

                       for (var i= 0; i < $scope.apiResult.length; i++) {
                            if ($scope.apiResult[i].Type == "Point"){
                              $scope.apiResult[i].visibility = true;
                              console.log($scope.apiResult)
                              console.log($scope.apiResult)
                              $scope.dataLatLng.push($scope.apiResult[i].LatLng)
                              $scope.Lat.push($scope.dataLatLng[i].split(',')[0]);
                              $scope.Lng.push($scope.dataLatLng[i].split(',')[1]);
                              L.marker([$scope.Lat[i], $scope.Lng[i]], {icon: greenIcon}).bindPopup($scope.apiResult[i].DESCRIPTION).addTo(cities);
                            }
                              // else if ($scope.apiResult[i].Type == "Polygon"){
                              //       $scope.PolyLine.push($scope.apiResult[i].LatLng)
                              //       console.log($scope.PolyLine)
                              //       // for (var i = 0; i < $scope.PolyLine.length; i++) {
                              //       //     $scope.polyLineCord.push($scope.PolyLine[i])
                              //       //     // console.log($scope.polyLineCord)
                              //       // }
                              //   }
                       }
               })
               if($scope.community[passedIndex].visibility)
                {
                  $scope.community[passedIndex].visibility = false;
                }
               else{
                 $scope.community[passedIndex].visibility = true;
                 $scope.stored = $scope.community[passedIndex];
               }
        }


          $scope.removeMarker = function (passedIndex) {
          if($scope.community.visibility)
           {
             $scope.community.visibility = true;
           } else {
                cities.clearLayers();
                $scope.stored.visibility = false;
              }
          }

0 个答案:

没有答案