Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Custom Canvas Rendering

    Hi,

    I'm trying to create a custom SmartGWT Canvas that will render mapping data (image tiles, paths etc). Due to requirements, I am forced to use the GWT integration so that I can get access to the Context2d object in GWT standard Canvas object. Here a snippet of what I'm trying to do.

    public class MapPane extends Canvas {

    com.google.gwt.canvas.client.Canvas baseCanvas;
    com.google.gwt.canvas.client.Canvas tileCanvas;

    public void initialise(){
    this.addChild(baseCanvas); // gwt canvas
    }

    public void render(){


    com.google.gwt.canvas.dom.client.Context2d context = tileCanvas.getContext2d();

    // for each preloaded tile image
    context.drawImage(tileImage, x, y);

    baseCanvas.getContext2d().drawImage(tileCanvas.getCanvasElement(), 0,0);
    }

    }

    Whenever a map event (zoom in, zoom out, pan) requires a redraw, I call my render() method to redraw the map. This, for the most part, work well but I'm having an issue with tile images not being rendered.

    Occasionally, some tiles will not render on the map even though they are loaded in cache and are available for rendering.

    Is there a better way of rendering/drawing custom components like this? Should I be calling another method to force redraw like 'repaint()' in a swing application?

    #2
    This isn't really enough information to comment - the best starting point is to read the DOM Integration overview in the docs.

    Comment

    Working...
    X