Class: IWMapRenderer

IWMapRenderer

A renderer to draw vector graphics like line, polygons, circles and so on a map. The renderer is responsible to project the data (which is specified in map coordinates) on the map and refresh the graphics after move and zoom events. The map renderer is based on IWGraphicsRenderer.

Example:

var attributes = { fill: 'red', stroke: 'black', strokeDashStyle: 'dashed' };

var renderer = new IWMapRenderer(map);
renderer.drawCircle(map.getCenter(), 1000, attributes); // draw a 1 km circle in the center of the map
renderer.render();

Rendering attributes:
Property Description Value Elements
fill the fill or text color CSS color description, e.g. #ff0000 or blue circle, ellipse, polygon, rectangle, rounded rectangle, text
fillOpacity the opacity of the fill color value between 0 (transparent) 1 (opaque) circle, ellipse, polygon, rectangle, rounded rectangle
stroke the stroke color CSS color description, e.g. #ff0000 or blue all
strokeOpacity the opacity of the stroke color value between 0 (transparent) 1 (opaque) all
strokeWidth the width of the stroke in pixels number all
strokeDashStyle the style of the stroke solid, dashed, or dotted all
strokeLinejoin the style of line joins round, bevel, or miter all
strokeLinecap the style of line ends round, butt, or square all
fontFamily the font family to render text e.g. sans-serif or Helvetica text
fontStyle the font style to render text e.g. italic or normal text
fontSize the font size to render text e.g. 14px text
fontWeight the font weight to render text e.g. bold or normal text
textDecoration the decoration to render text e.g. underline, overline or line-through text

This class is part of the module graphics.


new IWMapRenderer(map, order)

Parameters:
Name Type Description
map IWMap the map
order Array an array of strings defining the order of technologies (optional; the default order is ['svg', 'canvas'])

Methods


clearContainer()

Removes all DOM nodes from container.
Returns:
Type
void

drawCircle(center, radius, attributes)

Draws a circle with a specified center coordinate and radius in meters.
Parameters:
Name Type Description
center IWCoordinate the center of the circle
radius Number the radius in meters
attributes Object the rendering attributes

drawComplexPolygon(coords, holes, attributes)

Draws a complex polygon defined by the specified coordinates and holes.
Parameters:
Name Type Description
coords Array.<IWCoordinate> the coordinates
holes Array.<Array.<IWCoordinate>> an array of arrays of coordinates describing holes in the polygon
attributes Object the rendering attributes

drawEllipse(center, size, attributes)

Draws an ellipse with a specified center coordinate and with and height in meters.
Parameters:
Name Type Description
center IWCoordinate center of the ellipse
size IWSize the size of the ellipse
attributes Object the rendering attributes

drawLine(point1, point2, attributes)

Draws a line between the specified coordinates.
Parameters:
Name Type Description
point1 IWCoordinate first coordinate
point2 IWCoordinate second coordinate
attributes Object the rendering attributes

drawPolygon(coords, attributes)

Draws a polygon defined by the specified coordinates.
Parameters:
Name Type Description
coords Array.<IWCoordinate> the coordinates
attributes Object the rendering attributes

drawPolyline(coords, attributes)

Draws a polyline connecting all specified coordinates.
Parameters:
Name Type Description
coords Array.<IWCoordinate> the coordinates
attributes Object the rendering attributes

drawRectangle(center, size, attributes)

Draws a rectangle defined by it's center coordinate and size in meters.
Parameters:
Name Type Description
center IWCoordinate center of the rectangle
size IWSize the size of the rectangle
attributes Object the rendering attributes

drawRoundedRectangle(center, radius, size, attributes)

Draws a rounded rectangle defined by it's center coordinate and size in meters.
Parameters:
Name Type Description
center IWCoordinate center of the rectangle
radius Number the radius of the corners
size IWSize the size of the rectangle
attributes Object the rendering attributes

drawText(coord, text, attributes)

Draws a text on the map.
Parameters:
Name Type Description
coord the coordinate to render the text at
text the text to render
attributes Object the rendering attributes
Returns:
IWText

getElement(position)

Get the element on the specific position
Parameters:
Name Type Description
position Number position of the wanted element
Returns:
the element, e.g. an instance of IWPolygon
Type
object

moveToBottom(element)

Moves the element to the bottom by setting it to the first child in the DOM-structure.
Parameters:
Name Type Description
element DOMElement
Returns:
Type
void

moveToTop(element)

Moves the element to the top by setting it the to last child in the DOM-structure.
Parameters:
Name Type Description
element DOMElement
Returns:
Type
void

removeElement(element)

Removes a given DOM element from container
Parameters:
Name Type Description
element DOMElement
Returns:
Type
void

render()

Renders the shapes on the map.
Returns:
Type
void

shiftElement(element, position)

Moves an element to specific position
Parameters:
Name Type Description
element Object The vector object
position Number level position where the element shall be shifted to positive values will shift the graphic on the top negative values will shift the graphic on the bottom 'top' shift the graphic on the top 'bottom' shift the graphic on the bottom '0' no changes on the drawing container
Returns:
Type
void