GithubHelp home page GithubHelp logo

Comments (6)

sfairgrieve avatar sfairgrieve commented on June 29, 2024

Good question. You should be able to do this using the DataLayer displayOptions option. Under displayOptions, you should be able to map properties of your GeoJSON feature to Leaflet style options: https://github.com/humangeo/leaflet-dvf/wiki/8.-Datalayers.

Does this not work for you? Or do you need to do some mapping to style properties that involves multiple data properties found in a GeoJSON feature?

from leaflet-dvf.

codingisacopingstrategy avatar codingisacopingstrategy commented on June 29, 2024

Thanks for your swift reply—yes, I can rewrite my features so the gradient depends on one property only. I’ve been trying to setup a dataLayer that draws the GeoJSON instead of using a traditional leaflet GeoJson layer, but I think I’m doing something wrong:

var dataLayer = new L.DataLayer(data, {
    recordsField: 'features',
    locationMode: L.LocationModes.GEOJSON,
    layerOptions: {
        color: "#000000",
        fillOpacity: 0.7,
        opacity: 1,
        weight: 1,
        gradient: true
    },
    displayOptions: {
        gradient_stops: stops2gradient
    }
});
map.addLayer(dataLayer);

Full code @ http://jsfiddle.net/2JuzV/4/

Nothing gets drawn yet (also when I remove displayOptions). Could you give me some pointers on how to set up my dataLayer?

Cheers,

from leaflet-dvf.

codingisacopingstrategy avatar codingisacopingstrategy commented on June 29, 2024

EDT: fixed the link in the comment above to http://jsfiddle.net/2JuzV/4/

from leaflet-dvf.

sfairgrieve avatar sfairgrieve commented on June 29, 2024

Eric,

Try this: http://jsfiddle.net/2JuzV/12/

Is that what you're going for, or do you want to display markers rather
than polygons? Basically ChoroplethDataLayer will display and style
polygons, and DataLayer will display a marker centered at the polygon
centroid (need to include jsts.js for calculating the centroid).

Scott

On Wed, Jul 9, 2014 at 12:21 PM, Eric Schrijver [email protected]
wrote:

EDT: fixed the link in the comment above to http://jsfiddle.net/2JuzV/4/


Reply to this email directly or view it on GitHub
#32 (comment).

from leaflet-dvf.

codingisacopingstrategy avatar codingisacopingstrategy commented on June 29, 2024

Hey Scott—

Great, that does it! I hadn’t understood exactly the difference between the various types of DataLayers.

Added some more data points to the fiddle so you can see the gradient change with the longitude. (The polygons themselves represent parts of Russia where a high chance of rainbows is calculated, BTW :)

Cheers, Thanks

from leaflet-dvf.

sfairgrieve avatar sfairgrieve commented on June 29, 2024

Awesome, very cool!

Scott

On Thu, Jul 10, 2014 at 7:46 AM, Eric Schrijver [email protected]
wrote:

Hey Scott—

Great, that does it! I hadn’t understood exactly the difference between
the various types of DataLayers.

Added some more data points to the fiddle http://jsfiddle.net/2JuzV/14/
so you can see the gradient change with the longitude. (The polygons
themselves represent parts of Russia where a high chance of rainbows is
calculated, BTW :)

Cheers,


Reply to this email directly or view it on GitHub
#32 (comment).

from leaflet-dvf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.