Keep the examples simple

Please write blog posts, create tutorials, or develop workshops that show off cool ways to develop applications that use OL3.  The examples should be kept very simple.  This download functionality is neat, but it's really a gratuitous use of non-map related functionality.  While it does demonstrate the use of `format.writeFeatures()`, this is buried in too much additional code that is not accessible (buried in resources/common.js) and not really related to mapping things.  If we want to have examples that demonstrate how formats can be used to serialize features, a simple textarea would suffice as the target.
This commit is contained in:
Tim Schaub
2015-04-17 09:55:31 -06:00
parent c5cf709c55
commit 14b7edb140
6 changed files with 10 additions and 255 deletions

View File

@@ -63,29 +63,3 @@ map.on('pointermove', function(evt) {
map.on('click', function(evt) {
displayFeatureInfo(evt.pixel);
});
var exportKMLElement = document.getElementById('export-kml');
if ('download' in exportKMLElement) {
var vectorSource = vector.getSource();
exportKMLElement.addEventListener('click', function(e) {
if (!exportKMLElement.href) {
var features = [];
vectorSource.forEachFeature(function(feature) {
var clone = feature.clone();
clone.setId(feature.getId()); // clone does not set the id
clone.getGeometry().transform(projection, 'EPSG:4326');
features.push(clone);
});
var string = new ol.format.KML().writeFeatures(features);
var base64 = common.strToBase64(string);
exportKMLElement.href =
'data:application/vnd.google-earth.kml+xml;base64,' + base64;
}
}, false);
} else {
var info = document.getElementById('no-download');
/**
* display error message
*/
info.style.display = '';
}