Giter Club home page Giter Club logo

Comments (10)

bartvde avatar bartvde commented on July 19, 2024

so the current code needs a global function called createMapThumbnail

var createMapThumbnail = function(obj_id) {
    var xmap = $('.olMapViewport');
    height = xmap.height();
    width = xmap.width();
    var map = xmap.clone();
    map.find('*').each(function(i) {
        e = $(this);
        if(e.css('display') === 'none' || (e.attr("class") !== undefined && (e.attr("class").indexOf('olControl') >= 0 || e.attr("class").indexOf('x-') >= 0))) {
            e.remove();
        } else if (e.attr('src') === '/static/geoexplorer/externals/ext/resources/images/default/s.gif') {
            e.remove();
        } else {
            e.removeAttr("id");
        }
    });

    var url = window.location.pathname.replace('/view', '');

    if (typeof obj_id != 'undefined' && url.indexOf('new')){
        url = url.replace('new', obj_id);
    }

    url+= '/thumbnail';

    $.ajax({
        type: "POST",
        url: url,
        data: ("<div style='height:" + height + "px; width: " + width + "px;'>" + map.html() + "</div>"),
        success: function(data, status, jqXHR) {
            return true;
        }
    });
    return true;
};

from geonode-client.

jj0hns0n avatar jj0hns0n commented on July 19, 2024

from geonode-client.

bartvde avatar bartvde commented on July 19, 2024

@jj0hns0n can you tell me a bit more about the thumbnail endpoint? Can I post a base64 encoded image? Is it server-side rendering of HTML what Ian did?

from geonode-client.

jj0hns0n avatar jj0hns0n commented on July 19, 2024

from geonode-client.

bartvde avatar bartvde commented on July 19, 2024

We can do something similar to: http://openlayers.org/en/latest/examples/export-map.html

from geonode-client.

jj0hns0n avatar jj0hns0n commented on July 19, 2024

from geonode-client.

bartvde avatar bartvde commented on July 19, 2024

so it seems we need to also automatically update the thumbnail on save, like is done here?
https://github.com/GeoNode/geonode/blob/cea5011c2f735e83005bea013fa784034736d057/geonode/maps/templates/maps/map_geoexplorer.js#L34:L37

from geonode-client.

bartvde avatar bartvde commented on July 19, 2024

We also need to make sure that for our case thumbnail.js doesn't get included in the main geonode template: https://github.com/GeoNode/geonode/blob/23c42efc66b940875f76ea78ab457ffb3d07ebb6/geonode/maps/templates/maps/map_detail.html#L314

from geonode-client.

jj0hns0n avatar jj0hns0n commented on July 19, 2024

from geonode-client.

bartvde avatar bartvde commented on July 19, 2024

Right that's what we are working on now, but the standard template includes that thumbnail.js file when it shouldn't for the react viewer. Mila is working on a fix for that.

from geonode-client.

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.