JasonSanford / leaflet-vector-layers

A little help to viewing ArcGIS Server, Geocommons, Arc2Earth, CartoDB, GIS Cloud, etc. vector data in a Leaflet map
http://jasonsanford.github.io/leaflet-vector-layers
BSD 2-Clause "Simplified" License
216 stars 61 forks source link

Add setUser(), setRepo() and setFeatureSet() to GitSpatial #55

Closed kbsali closed 10 years ago

kbsali commented 10 years ago

This makes it possible to "change" the layer Gitspatial layer source without having to create a new instance of lvector.GitSpatial

See http://gasolineras.saliou.name/ for a live example.

JasonSanford commented 10 years ago

Hi Kevin, thanks for the addition.

I'm thinking this might be something obscure enough that you should maybe just sublcass lvector.GitSpatial. For example:

MyGitSpatial = lvector.GitSpatial.extend({
    setUser: function(user) {
        this.options.user = user;
    },

    setRepo: function(repo) {
        this.options.repo = repo;
    },

    setFeatureSet: function(featureSet) {
        this.options.featureSet = featureSet;
    }
});

my_layer = MyGitSpatial({
    user: 'whoever',
    repo: 'whatever',
    featureSet: 'whatever_again'
});

// The custom methods are now available since my_layer was instantiated from MyGitSpatial, your subclass of lvector.GitSpatial
my_layer.setFeatureSet('another_feature_set');
kbsali commented 10 years ago

ok that works for me, although i still think this would be a nice built-in feature! ;)