**hello everyone… i am new to cesium and javascript … i am developing a web application in which when user clicks on any pin billboard an iframe information box is displayed in which i have provided a HTML field box and a clickable button …now i want to create a function by using which a .txt file could be generated and saved in system using string provided by user when he clicks that button . **
**is this possible …pin’s color could be changed to another one… (eg. from blue to red) when user clicks submit button…(or a new pin could generate automatically at the same coordinate when user clicks that button…?) **
**i am using crome **
here is the sample code that i have been using
//Sandcastle_Begin
var viewer = new Cesium.Viewer(‘cesiumContainer’, {timeline : false, animation : false});
var toolbar = document.getElementById(‘toolbar’);
var pinBuilder = new Cesium.PinBuilder();
var numClicks = 0;//an variable
viewer.infoBox.frame.removeAttribute(‘sandbox’);
//viewer.selectedEntity = entity;//Gets or sets the object instance for which to display a selection indicator.
////////////////////////////
//disabling iframe sandbox
///////////////////////////
var iframe = document.getElementsByClassName(‘cesium-infoBox-iframe’)[0];
iframe.setAttribute(‘sandbox’, ‘allow-same-origin allow-scripts allow-popups allow-forms’);
viewer.infoBox.frame.sandbox = "allow-same-origin allow-top-navigation allow-pointer-lock allow-popups allow-forms ";
///////////////////////////
//adding a function
///////////////////////////
//function updateDisplay() {
// var x, y,z;
//x=document.getElementById(“form1”);
//y=x.elements[“form1”];
//y=x.CreateTextFile(“C:\test.txt”);
//}
//updateDisplay();
//function updateDisplay() {
// toolbar.innerHTML = 'Number of times you clicked either button: ’ + numClicks;
//}
//updateDisplay();
//////////////
//adding pin
//////////////
var bluePin = viewer.entities.add({
name : ‘Blank blue pin’,
position : Cesium.Cartesian3.fromDegrees(-75.170726, 39.9208667),
description :‘
’ +‘
’ +‘
’ +‘
’ + //adding click button‘
POLE LOCATION | ’ + (‘-75.170726, 39.9208667’) + ‘ |
---|---|
HOUSE ID | ’ + (‘A/64’) + ‘ |
FILE COMPLAINT | ’ +
(‘name:’) + (‘ Click here ’) +
‘ |
billboard : {
image : pinBuilder.fromColor(Cesium.Color.ROYALBLUE, 48).toDataURL(),
verticalOrigin : Cesium.VerticalOrigin.BOTTOM
}
});
//Since some of the pins are created asynchronously, wait for them all to load before zooming/
//Cesium.when.all([bluePin], function(pins){
// viewer.zoomTo(pins);
//});
///////////////////////////
//adding a function
///////////////////////////
//function updateDisplay() {
//var x, y,z,name;
//x=document.getElementById(“form1”);
//y=x.elements[“name”];
//y=x.CreateTextFile(“C:\test.txt”);
//}
//updateDisplay();
viewer.infoBox.frame.addEventListener(‘load’, function() {
//
// Now that the description is loaded, register a click listener inside
// the document of the iframe.
//
viewer.infoBox.frame.contentDocument.body.addEventListener(‘click’, function(e) {
//
// The document body will be rewritten when the selectedEntity changes,
// but this body listener will survive. Now it must determine if it was
// one of the clickable buttons.
//
if (e.target && e.target.className === ‘click-test-button’) {
++numClicks;
updateDisplay();
}
}, false);
}, false);