CanvasMap
Getting Started Tutorials 3D Reference

Class CMLayerGraticule extends CM2Layer

CMLayerGraticule

by: Jim Graham

This class required a level of complexity beyond what I initially expected.
The problem is that we have to:
- Draw graticule lines based on the zoom level, projection, and area viewed
- Paint coordinates along the border based on where the graticules intersect with the border
- Paint coordinates along the outside of the graticule grid if it is visible (i.e. does not
intersect with the border.

Settings used are:
- Style: for lines
- TextStyle: for labels in the map

Graticles are made visible by setting the overall style to transparent. The graticules must be drawn to get the intersections for the exterior and border

Settings Group: Graticule

Setting Name Type Options Default Comments
East East CMTYPE_FLOAT 180
West West CMTYPE_FLOAT -180
North North CMTYPE_FLOAT 90
South South CMTYPE_FLOAT -90
Spacing Spacing CMTYPE_FLOAT 200 / desired spacing for the graticules in pixels
DegreeSpacing Degree Spacing CMTYPE_FLOAT -1 only implemented for 3d
TextSpacing Text Spacing CMTYPE_FLOAT 360 only implemented for 3d

Settings Group: Border

Setting Name Type Options Default Comments
strokeStyle Line Style CMTYPE_CSS_STYLE rgb(0,0,0)
fillStyle Fill Style CMTYPE_CSS_STYLE rgb(255,255,255)
lineWidth Width CMTYPE_INTEGER 3
BorderWidth Border Width CMTYPE_FLOAT 12

Settings Group: BorderText

Setting Name Type Options Default Comments
font Font CMTYPE_FONT 14px Arial
strokeStyle Line Style CMTYPE_CSS_STYLE rgb(0,0,0)
lineWidth Width CMTYPE_INTEGER 1
fillStyle Fill Style CMTYPE_CSS_STYLE rgb(0,0,0)