Tools to draw on the map canvas.
Usage
Load the file /modules/miniature.earth.mapdraw.js or copy the code to your script and customize it to your needs.
Earth.MapDraw.enable.enable( earth )
myearth.addEventListener( 'drawtexture', function( event ) {
Earth.MapDraw.enable( this );
this.drawPolygon(
bermuda_triangle,
{
color: 'RGBA(0,255,0,0.2)'
}
);
};
Methods
EarthInstance.drawLine( locations, style )
- locations
- (array) Array of lat/lng objects.
- style
- (object) Object of drawing options:
strokeColor | default: #FF0000
strokeWidth | default: 1
Draws lines between the given locations.
EarthInstance.drawPolygon( locations, style )
- locations
- (array) Array of lat/lng objects.
- style
- (object) Object of drawing options:
color | default: RGBA(255,0,0,0.25)
strokeColor | default: #FF0000
strokeWidth | default: 0
Like drawLine but also draws a line from frist to last location and can be filled with a color.
EarthInstance.drawPoint( location, style )
- location
- (lat/lng) The location of the point.
- style
- (object) Object of drawing options:
color | default: #FF0000
size | default: 1
Draws a point while compensating for the map projection/distortion.
EarthInstance.loadMapLayer( image_url )
- image_url
- (URL string) Provide a URL to an image from the same domain or use a dataURI.
The SVG format is recommended but it is also possible to use a PNG as a layer.
The image must be in 2:1 format, with equirectangular projection.
If you draw on the map after the
drawtexture event, you must call
EarthInstance.
updateMap() to apply the updated map.