The second hack for making proportional symbols in KML, is to use
regular polygons (see the first hack
here and
here). Unfortunately, KML has no build-in support for regular polygons so you have to do it the hard way: by calculating the longitude/latitude for each vertex or corner point of the polygon. Since I'm not a math genius, I was happy do find
this PHP function by TJ which I could modify for this purpose. This is the result:
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWhyphenhyphenTtIbl6r7vrsvsMS1ERssHVtyKx6gHecY2NrxSJZzJYDb35Mqv_9xhI6P0zfRjMMY8XNg064GYPdYwmrq3UerNW1psz3unS5nHm9zXmhcmT35ZU4QDXuzZbRsMh_wduHJAdeRd_FIA/s400/google_earth_regular_polygons_circle.png)
By changing the bearing or angle 30 times from 0 to 360, the function returns a circle (
KMZ).
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhR29jtHEUeMv3_eV6CI_0gqg7pOXCDSDYAmeQX2-uMS8PNQ1oM0G46gPUtRkMbFRNqE2L_-B_qPRcnAI8carMh_Jaxria6OjePjj7_u2MztLGGzXAPZIAyGwiNWExn2B_NuLD8cNm7bPU/s400/google_earth_regular_polygons_square.png)
Reduce the number of iterations to 4, and you'll get a square (
KMZ). Not the easiest way to draw a square, but it works.
These files are also viewable in
Google Maps and
Microsoft Live Maps (Virtual Earth), even though the circles are not so regular any more.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEitOn0GrRZJpOlrwGQW0tsw41YjHA2KOorScJeomRhafChF8NX0n-BBoKRQ3B9156pCCBDQMNBz6IESvZV2miTqPSTkgQQqIsey5Qf8OmG3v95xXRbvuCng2XhReAvhGUvTsxslBJFtoys/s400/google_maps_squares.png)
2 comments:
Is it possible to see the code that generates the KML-files?
could you please post the link to the php function by TJ
Post a Comment