TextImage Module

Creates images of text for use with Sprite and Image objects.

Example: Text Images

Usage

Load the file /modules/miniature.earth.textimage.js or copy the code to your script and customize it to your needs.

Methods

Earth.TextImage.draw( text, options )

text
(string) The text to be drawn. Use \n for a line break.
options
(object) Object of text style options:
fontFamily | default: sans-serif
fontWeight | default: ""
fontStyle | default: ""
lineHeight | default: 1
quality | default: 1

Returns an object with image, scale and resolution for use with Sprite and Image objects.

var text_image = Earth.TextImage.draw(
	'North\nAmerica',
	{
		fontFamily : 'MyFont, sans-serif',
		fontWeight : 'bold'
	}
);

myearth.addImage( {
	location : { lat: 39, lng : -98 },
	image : text_image.image,
	scale: text_image.scale * 0.8,
	imageResolution : text_image.resolution,
	color: '#333'
} );
 
If you use a custom font, it must be loaded when drawing the TextImage. You are safe after the window.load event.