Currently, I am creating icons in Google Earth using the following Javascript code:

// Define a custom icon.
var icon = ge.createIcon('');
icon.setHref('http://myserver/marker.png');

What I would like to be able to do, is have an "offline" version of this that simply either styles the current placemarker icon (e.g. change its color) or use some sort of colored circle using KML. I have already ruled out the possibility of using a local file.

Is this even possible with Google Earth API without using a remote icon URL?

有帮助吗?

解决方案

Sure, you can control the colour and size of the icons directly via the api. For example to set the size and colour of the placemark icon...

var icon = ge.createIcon('');
var style = ge.createStyle('');

style.getIconStyle().setIcon(icon); 
style.getIconStyle().setScale(5.0); // size

var colorMode = style.getIconStyle().getColor(); 
colorMode.set("ff000000"); // colour
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top