Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

thumbnail generation code #88

Open
bartvde opened this issue Jan 13, 2017 · 10 comments
Open

thumbnail generation code #88

bartvde opened this issue Jan 13, 2017 · 10 comments
Assignees
Milestone

Comments

@bartvde
Copy link
Collaborator

bartvde commented Jan 13, 2017

We should update the thumbnail generation code so that we can generate them from the canvas instead

@milafrerichs milafrerichs modified the milestone: 1.0.0 Jan 31, 2017
@bartvde
Copy link
Collaborator Author

bartvde commented Jan 31, 2017

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;
};

@bartvde bartvde self-assigned this Jan 31, 2017
@jj0hns0n
Copy link
Contributor

jj0hns0n commented Jan 31, 2017 via email

@bartvde
Copy link
Collaborator Author

bartvde commented Jan 31, 2017

@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?

@jj0hns0n
Copy link
Contributor

jj0hns0n commented Jan 31, 2017 via email

@bartvde
Copy link
Collaborator Author

bartvde commented Jan 31, 2017

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

@jj0hns0n
Copy link
Contributor

jj0hns0n commented Jan 31, 2017 via email

@bartvde
Copy link
Collaborator Author

bartvde commented Feb 2, 2017

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

@bartvde
Copy link
Collaborator Author

bartvde commented Feb 2, 2017

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

@jj0hns0n
Copy link
Contributor

jj0hns0n commented Feb 2, 2017 via email

@bartvde
Copy link
Collaborator Author

bartvde commented Feb 2, 2017

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants