Adding support for "Data URLs" to KML files

elmuSSo shared this idea 5 years ago
Completed

Firstly, to understand what "Data URL" is, please copy and paste text below to your browser address line:


data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAARhJREFUOMulk1FOwzAQRN+WKBKX4wL8cgEOhPhFiDtwJtTGadPsDh9OGsdpEYhIkVdKdvbN2G4k8Z+nAQzYmdn42yZJd4AANQBt244v7yL1sO/gaw+HBB7gLtyLNUTbtj4Mww6gMbN4/RD9CVIP3TGvIYgQEbkuRR6eEmYWkqwBGM6QUm7uOhgDfJwJcmMWhFCuywzy5B66lMUiiumhhUbLt6sCxxPVz5WIlN+oCA4pi2Rs3QzP4wcCDwhKzImGxfdCVBGcx6Kp9l3a8GXISuCCWqNPuzD7ntfy9DZwJTStw/NxK7IWWPmexNhunxAS6KYFp0pcl8bVEC8sSDIz0+OzF2lvz4CkfHskPt/ukWQXglnkD7fR5vobMReYrqV+SAwAAAAASUVORK5CYII=


or read about it here: http://dataurl.net/#about


IDEA: I would like to ask for adding a support of Data URLs in KML files. This would be amazing feature for using dynamically generated KML from network links. With using Data URLs there would be no need to pack KML into KMZ format just to put an icon into it. With Data URL, a programmer would be able generate an icon on the server side and just put it into KML file served via http. The target KML will look like this:


<?xml version="1.0" encoding="UTF-8"?>


<kml xmlns="http://www.opengis.net/kml/2.2"; xmlns:gx="http://www.google.com/kml/ext/2.2"; xmlns:kml="http://www.opengis.net/kml/2.2"; xmlns:atom="http://www.w3.org/2005/Atom">;


<Document>


<name>KmlFile</name>


<Style id="myPositionStyle">


<IconStyle id="myPositionIcon">


<Icon><href>data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAARhJREFUOMulk1FOwzAQRN+WKBKX4wL8cgEOhPhFiDtwJtTGadPsDh9OGsdpEYhIkVdKdvbN2G4k8Z+nAQzYmdn42yZJd4AANQBt244v7yL1sO/gaw+HBB7gLtyLNUTbtj4Mww6gMbN4/RD9CVIP3TGvIYgQEbkuRR6eEmYWkqwBGM6QUm7uOhgDfJwJcmMWhFCuywzy5B66lMUiiumhhUbLt6sCxxPVz5WIlN+oCA4pi2Rs3QzP4wcCDwhKzImGxfdCVBGcx6Kp9l3a8GXISuCCWqNPuzD7ntfy9DZwJTStw/NxK7IWWPmexNhunxAS6KYFp0pcl8bVEC8sSDIz0+OzF2lvz4CkfHskPt/ukWQXglnkD7fR5vobMReYrqV+SAwAAAAASUVORK5CYII=</href>


</Icon>


</IconStyle>


</Style>


<StyleMap id="myPositionStyle0">


<Pair>


<key>normal</key>


<styleUrl>#myPositionStyle</styleUrl>


</Pair>


<Pair>


<key>highlight</key>


<styleUrl>#myPositionStyle1</styleUrl>


</Pair>


</StyleMap>


<Style id="myPositionStyle1">


<IconStyle id="myPositionIcon">


<Icon><href>data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAARhJREFUOMulk1FOwzAQRN+WKBKX4wL8cgEOhPhFiDtwJtTGadPsDh9OGsdpEYhIkVdKdvbN2G4k8Z+nAQzYmdn42yZJd4AANQBt244v7yL1sO/gaw+HBB7gLtyLNUTbtj4Mww6gMbN4/RD9CVIP3TGvIYgQEbkuRR6eEmYWkqwBGM6QUm7uOhgDfJwJcmMWhFCuywzy5B66lMUiiumhhUbLt6sCxxPVz5WIlN+oCA4pi2Rs3QzP4wcCDwhKzImGxfdCVBGcx6Kp9l3a8GXISuCCWqNPuzD7ntfy9DZwJTStw/NxK7IWWPmexNhunxAS6KYFp0pcl8bVEC8sSDIz0+OzF2lvz4CkfHskPt/ukWQXglnkD7fR5vobMReYrqV+SAwAAAAASUVORK5CYII=</href>


</Icon>


</IconStyle>


</Style>


<Placemark id="placemark0">


<name>Test</name>


<description>21:38:48 - 2013/08/25</description>


<styleUrl>#myPositionStyle0</styleUrl>


<gx:balloonVisibility>1</gx:balloonVisibility>


<Point>


<coordinates>22.18449,52.3943,224.7</coordinates>


</Point>


</Placemark>


</Document>


</kml>


I`m aware this is very specific idea, and nobody normal will support it. But I believe it will be useful for someone at sometime in the future. As a curiosity I can tell you that even Google Earth is not supporting this great feature, which is very sad, because it can eliminate the need of creating a KMZ file ( which is not cool to create it dynamically on server side ).


I would like to hear your opinions.

Comments (4)

photo
0

oki, simple task. Icons for points now support images encoded in Base64


currently, data needs to starts with data:image/png;base64,. Are there any other formats used here?

photo
0

Wow. I`m amazed. Big thanks for that kamo!!! I will try to look if there is more useful formats, but this png should cover most of the cases. Icons are usually in png.

photo
0

These can be useful:


image/gif


image/jpeg


image/png


image/tiff


image/vnd.microsoft.icon - this is for .ICO files, so it is important

photo
0

oki fine, so it should all work, but it depend how will creating images from this base64 encoded text handle android. PNG and JPG will probably not be a problem. GIF maybe also not, TIFF probably yes. Anyway PNG is most important and it will work