logo
down
shadow

Using filter with geojson, right direction?


Using filter with geojson, right direction?

By : user2950687
Date : November 17 2020, 11:58 AM
this one helps. You're injecting $filter and filterFilter into your controller, but you're not actually assigning one of them to your scope. Meanwhile you are assigning $scope.filter to the filter property of your geojson declaration. That won't work because $scope.filter isn't declared. Before extending the scope with your geojson declaration you've got to assign the filter to the scope: $scope.filter = filterFilter or $scope.filter = $filter, depending on which on you need. That's unclear to me since i can't see what $filter and filterFilter contain.
code :
// assign filterFilter to the $scope
$scope.filter = filterFilter;
// or assign $filter to the $scope
$scope.filter = $filter;

angular.extend($scope, {
    geojson: {
        data: filterFilter($scope.hf_directory, $scope.search),
        filter: $scope.filter
    }
});


Share : facebook icon twitter icon
How do I keep GeoJSON style after filter?

How do I keep GeoJSON style after filter?


By : user3228234
Date : March 29 2020, 07:55 AM
help you fix your problem When you apply a filter, the filtered features get re-added to the layer, since you only apply the style on the ready event when you at first load the features and they get added, you'll lose the style when you use the filter because of the re-adding. You should apply the style again after you use the filter, try something like this:
code :
var featureLayer = L.mapbox.featureLayer('http://run.plnkr.co/1zb4Lj1NPtpu4MAM/data.geo.json').addTo(map);

// Fetch available inputs
var inputs = document.querySelectorAll('input.filter');

// Loop over inputs
for (i = 0; i < inputs.length; i++) {
  // Attach events
  inputs[i].onchange = function () {
    // Run filter on inputchange
    filter();
  }
}

// Object to hold the colors
var colors = {
  '1': 'red',
  '2': 'yellow',
  '3': 'blue'
};

// Method which applies style
var setStyle = function () {
  // Loop over layers in featureLayer
  featureLayer.eachLayer(function (layer) {
    // Set style on layer
    layer.setStyle({
      // set colors from object 
      fillColor: colors[layer.feature.id],
      color: colors[layer.feature.id]
    });
  });
}

// Filter function
var filter = function () {
  // Array for checked inputs
  var checked = [];
  // Loop over inputs
  for (i = 0; i < inputs.length; i++) {
    // See if input is checked
    if (inputs[i].checked) {
      // Is checked add to array
      checked.push(Number(inputs[i].value));
    }
  }
  // Set filter function on array
  featureLayer.setFilter(function (feature) {
    // return true is feature.id is in checked array
    return (checked.indexOf(feature.id) != -1);
  });
  // Call style function
  setStyle();
}

// Run filter when featureLayer is ready
featureLayer.on('ready', filter);
filter geojson by date

filter geojson by date


By : user3256527
Date : March 29 2020, 07:55 AM
like below fixes the issue Where does it say in the specifications that that's not possible? According to the specification a GeoJSON feature object must have a properties member which should be an object (or null):
code :
{
    "type": "Feature",
    "properties": {
        "myProperty": "myValue"
    },
    "geometry": {
        "type": "Point",
        "coordinates": [0, 0]
    }
}
new Schema({
    'type': {
        type: String,
        default: 'Feature'
    },
    properties: {
        date: {
            type: Date,
            default: Date.now
        }
    },
    geometry: {
        type: {
            type: String,
            default: 'Point'
        },
        coordinates: {
            type: [Number]
        }
    }
});
How to filter a large geojson file in R

How to filter a large geojson file in R


By : Rod
Date : March 29 2020, 07:55 AM
Does that help I'm having issues filtering a large geojson file with R. If I just want to show the map for one country, I don't want the entire map of europe to be loaded which is huge. So I want to filter this dataset for example for Bulgaria -- CNTR_CODE == "BG" but I can't manage. Please find code to download below and an initial effort which doesn't result in the desired outcome , If you want a list, then Filter could work:
code :
path = "NUTS_RG_01M_2013_4326_LEVL_3.geojson"
x <- jsonlite::fromJSON(path, simplifyVector = FALSE)
x$features <- Filter(function(z) z$properties$CNTR_CODE == "BG", x$features)
vapply(x$features, function(x) x$properties$CNTR_CODE, "")
path = "NUTS_RG_01M_2013_4326_LEVL_3.geojson"
x <- paste0(readLines(path), collapse = "")
xx <- jqr::jq(x, '.features |= map(select(.properties.CNTR_CODE == "BG"))')
jqr::jq(xx, '.features[].properties.CNTR_CODE')
Filter geojson TS

Filter geojson TS


By : user3462024
Date : March 29 2020, 07:55 AM
Hope that helps I work with angular 8. I have a geojson fille in my asset folder : , The following rxjs operators should filter the way you want:
code :
import { of } from 'rxjs'; 
import { filter, flatMap, map } from 'rxjs/operators';

let filteredData = this.http.get('assets/es.json').pipe(
  map(response => JSON.parse(response)),
  flatMap(obj => obj.features),
  filter((feature: any) => feature.properties.t == 2)
);

filteredData.subscribe(x => {
  console.log(x);
});
cluster filter geojson mapbox

cluster filter geojson mapbox


By : Will Scotsman
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , The filter will not update the cluster group layer. You have to update it too.
Related Posts Related Posts :
  • AngularJS - Does $resource requests send cookies automatically?
  • Communication between two nested directives angularjs
  • what can or cannot be done with a controller created in a module Vs controller created globally?
  • Angularjs - add ng-* attributes using directives
  • Why are my Angular, absolute path, URL's not compiling properly with Closure Compiler?
  • AngularJS routing not working properly in PhoneGap
  • AngularJS: Create new scope variable name using a variable value
  • Directive scope update does not update controller scope (AngularJs)
  • Unit-test a angular controller function in a directive
  • jQuery Sparkline in a cell in ng-grid using CellTemplate and Directive
  • AngularJS determine filter in controller
  • How to deploy an app using ionic framework to Amazon? (elastic beanstalk prefered)
  • Conditional injection of a service in AngularJS
  • Filtering on object properties not working
  • Open $modal from the service and pass variables to the controller
  • ngClick evaluated against scope instead of isolateScope
  • onEnter and onExit are not called when state is left/activated in angularjs ui router
  • Shared client & server modules with angularjs and pongular
  • Getting the angular app to run when using protractor
  • Angularjs: create a link for download different types of file
  • AngularJS: On Change of Parent DropDown Option Also Changes the Dependant Drop Down Options Associated with Other Parent
  • Angular HTML5 mode, Wordpress, Rewrites, Apache and You
  • Using angular js form validations in <form:input> tag
  • AngularJS call common functions in a directive template
  • AngularJS Promise resolved incorrectly
  • properly clearing whole AngularJS ui-grid chart
  • Can not figure out how to store $rootScope in angular.bootstrap
  • animate.css animation within angularjs 1.3 using ngAnimate gives different animations in Firefox
  • Auth0 IE Issue: Unable to get property 'frames' of undefined or null reference
  • Am I misusing directives with too much logic?
  • Use an Angular JS value as a parameter of TWIG "path" function in Symfony 2
  • multiple function on ng-click angularjs
  • Converting $.ajax call to $http call in angular 404 error
  • Angularjs templateUrl file location not found
  • How to execute the function after change page in angularjs?
  • Pass variable to AngularJS directive without isolated scope
  • OAuth, Custom Login, or Both
  • Angular Directive: Isolate Scope & Transclude is true, but HTML in the directive needs to continue to bind to parent
  • Compare objects in angularjs
  • Combine "Checkbox" & "Avatar" in an Ionic Framework List
  • Issue with the Angular UI router when inheriting from a parent state
  • Is there a way to initialize an Angular Service without DI into controller
  • Why is a parent controller's $scope not accessible from a (child) directive?
  • How to get back button in Ion-tabs page
  • AngularJS bind class attribute to model
  • How can I get AngularJS ui-router to respond correctly to a browser page refresh?
  • Angular validation does not work
  • Breez Create Complex Entities
  • Drag and drop using protractor in dthmlx component
  • In Angular JS, what is the default 'cache' value that is used when sending request with $http service?
  • How to change placeholder for single textbox in angular?
  • $ is not defined - jquery angular mixing
  • CORS issue angularjs and spring security
  • Angularjs cannot select last item in dropdown the first time
  • Angularjs - $watch issue
  • On change radio button to no the span should hide in angular
  • Creating a wordcloud generator in Angularjs
  • Angular UI Bootstrap collapse - whats wrong?
  • AngularJS after redirect from app to app, the default page is not loading
  • Why does my scope update my factory and my factory update my scope when it should not?
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org