- Legend to Symbols

-
Class nokia.maps.gfx.GraphicsImage
The class GraphicsImage is designed to render images within
the client application at run time. The graphics image is not rendered at
construction time for the same reason that a bitmap image is not loaded
at construction time: rendering occurs when it is really necessary.
Imagine there are 1000 map objects and the image for each object must be
rendered depending on the properties of the object, for example, because
the object contains traffic information. It would cost large amounts of
CPU time to render all the images and consume a lot of memory to keep
the image data in memory while perhaps only a few of the objects may be
visible in the current view.
The rendering of a graphics image is done by a function that is not called as soon as the image is needed. The same function can be used for multiple graphics images, therefore it is possible to implement a multi-painter, so a function that renders all markers and uses the marker properties as a source of information about how to render the markers.
It is also possible to create an instance of GraphicsImage
without a rendering function, but using a pre-created
nokia.maps.gfx.IDL or nokia.maps.gfx.Graphics context.
// Create a few shortcuts.
var GraphicsImage = nokia.maps.gfx.GraphicsImage,
Color = nokia.maps.gfx.Color,
parseCss = Color.parseCss;
// Create a reference to the document body.
var body = document.body || document.documentElement;
// Create a new graphics image.
var image = new GraphicsImage( function( graphics, graphicsImage ) {
// This will clear the canvas and set it's size to 64 x 64 pixel
graphics.beginImage(64, 64, "MyImage");
// Let's draw a circle with a 2 pixel black border and fill it with semi
// transparent red color
graphics.set("lineWidth", 2 );
graphics.set("strokeColor", parseCss("black"));
graphics.set("fillColor", parseCss("red", 0.5));
// Create the path using a helper function.
graphics.drawEllipse(16,16, 32,32);
// Stroke and fill the path.
graphics.stroke();
graphics.fill();
});
// Add the graphics image to the body.
body.appendChild( image.createElement() );
createElement().
GraphicsImage (true) or not (false).
This method creates a new graphics image instance.
// Create a few shortcuts.
var GraphicsImage = nokia.maps.gfx.GraphicsImage,
Color = nokia.maps.gfx.Color,
parseCss = Color.parseCss;
// Create a reference to the document body.
var body = document.body || document.documentElement;
// Create a new graphics image.
var image = new GraphicsImage( function( graphics, graphicsImage ) {
// This will clear the canvas and set it's size to 64 x 64 pixel
graphics.beginImage(64, 64, "MyImage");
// Let's draw a circle with a 2 pixel black border and fill it with semi
// transparent red color
graphics.set("lineWidth", 2 );
graphics.set("strokeColor", parseCss("black"));
graphics.set("fillColor", parseCss("red", 0.5));
// Create the path using a helper function.
graphics.drawEllipse(16,16, 32,32);
// Stroke and fill the path.
graphics.stroke();
graphics.fill();
});
// Add the graphics image to the body.
body.appendChild( image.createElement() );
| {Function | nokia.maps.gfx.IDL | nokia.maps.gfx.Graphics} | render_fn |
A function to be called as soon as the image is required; the function
gets as its first argument the graphics context (an instance of
nokia.maps.gfx.Graphics) that it uses to render
the image, and as a second parameter an instance of
nokia.maps.gfx.GraphicsImage, which represents the
image to render; if the constructor is called with additional arguments,
these are forwarded as additional arguments to the rendering function;
optionally, an instance of nokia.maps.gfx.IDL or
nokia.maps.gfx.Graphics context can be supplied to
create a new graphics image instantly
|
| {Object} | [context]: |
The context in which the rendering function is to be executed; if not
specified the context (this) is bound to the given instance
of nokia.maps.gfx.GraphicsImage
|
| {Document} | [doc]: | The document to which the given graphics image is bound; if omitted, the image is bound to the current document |
| {nokia.maps.gfx.Painter} | [painter]: |
The painter to be used to paint; if not supplied, the painter currently
assigned to the static property defaultPainter of the class
nokia.maps.gfx.Painter is used; if this argument has an invalid
value, it is ignored and the defaultPainter is used
|
| {Object} | [args...]: | An arbitrary number of additional arguments to be forwarded to the rendering function |
| {nokia.maps.gfx.IDL} | The IDL generated by the given instance of graphics context |