Giter Site home page Giter Site logo

Comments (3)

Gagaro avatar Gagaro commented on June 3, 2024

Hi, thanks for the issue, it actually made me find a typo preventing this which dated back to 2013!

I was able to do what you wanted by customizing the FieldStore:

class LineWidget(LeafletWidget):
    include_media = True
    map_template = 'leaflet/admin/widget.html'
    modifiable = True
    map_width = 'min(calc(100vw - 30px), 720px)'
    map_height = '400px'
    field_store_class = 'L.Field3DStore'

    class Media:
        js = ['leaflet/leaflet.forms.js', 'leaflet.3d.js']


class LineTestForm(forms.ModelForm):
    class Meta:
        model = LineTest
        fields = ['line']
        widgets = {
            'line': LineWidget
        }


class LineTestAdmin(LeafletGeoAdmin):
    form = LineTestForm


admin.site.register(LineTest, LineTestAdmin)

leaflet.3d.js:

L.Field3DStore = L.FieldStore.extend({
    _serialize: function (layer) {
        const geojson = JSON.parse(L.FieldStore.prototype._serialize.call(this, layer));
        for (const coordinate of geojson.coordinates) {
            coordinate.push(0);
        }
        return JSON.stringify(geojson);
    }
});

I'll release the fix ASAP so you can try it yourself (you can use master in the meantime).

from django-leaflet.

Gagaro avatar Gagaro commented on June 3, 2024

Released in 0.28.2

from django-leaflet.

florianm avatar florianm commented on June 3, 2024

Thanks for the lighting quick turnaround, I'll give it a whirl!

from django-leaflet.

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.