|Inside the KML Placemark|
|Written by Mike James|
|Tuesday, 05 October 2010|
Page 6 of 6
As an example the following draws two rectangles one in green and one in red:
Notice that now as we have two Placemarks we have to bundle them up into a single ??Document.
One of the uses of geometric objects is to create a custom place marker without the need to use a custom bitmap icon. To do this you generally need to generate the KML using a script.
For example to generate an n-sided polygon of radius r and centered on x,y you might use:
As this only generates the necessary co-ordinates you have to embed it in sutiable KML tags.
generates the co-ordinates for a triangle centered on -1,55 and radius 1.
These can be copied and pasted into the co-ordinate section of a polygon to give:
You can create any polygon marker in the same way and even approximate a circle if you set n big enough. For example, n=25
The reason the "circle" is in fact an ellipse is that we are working with latitude and longitude as if they were measures of linear distance. How much distance a degree of longitude represents depends on the latitude. To make this shape generator position-independent you need to scale the latitude and longitude so that you are working in ground distances - not difficult but something for another article.
|Last Updated ( Tuesday, 05 October 2010 )|