Hello,
I hope this isn’t considered off topic here. It does have to do with using Cesium. I’m kind of a novice when it comes to modern html (HTML5/JQuery/CSS, etc).
All of the implementations I am finding on the Cesium web site involve running cesium as a widget in a div container.
I have a need for a small text search form that exists outside of this div container.
It consists of one form input and a couple of buttons. This form allows a user to enter search terms that I run against a database, and pull out associated coordinates that I am creating pins to place on the Cesium app.
I would like this form to sit on top (overlay) the div container that contains the cesium widget.
I just figured other people in this group may have had to do
something similar. Any helpful hints on slick ways for doing this (including likes to widgets) would be
appreciated.
Thanks!
var viewer = new Cesium.Viewer('cesiumContainer');
function addUpperLeftDiv() {
var divUL = document.getElementById('divUpperLeft');
if (!divUL) {
divUL = document.createElement('div');
divUL.id = 'divUpperLeft';
divUL.style.position = "absolute";
divUL.style.background = "rgba(0,0,0,0)";
divUL.style.left = "10px";
divUL.style.top = "10px";
divUL.innerHTML = "";
divUL.style.zIndex = 2000;
document.getElementById("cesiumContainer").appendChild(divUL);
}
}
function includeSearchWidget() {
var divContainer = document.createElement("div");
divContainer.id = "divSearchContainer";
divContainer.style.top = "20px";
var txtField = document.createElement("input");
txtField.id = "txtSearchField";
txtField.type = "text";
txtField.style.border = "0px solid";
txtField.style.width = "150px";
txtField.onkeydown = function(e) {
// Enter Key
var keycode = e.which ? e.which : e.keyCode;
if (keycode === 13) {
window.alert("You hit the enter key while focus was on the search text field!");
}
};
divContainer.appendChild(txtField);
var btnSearch = document.createElement("input");
btnSearch.id = "btnSearch";
btnSearch.type = "button";
btnSearch.value = "Go";
btnSearch.style.width = "50px";
btnSearch.style.marginLeft = "10px";
btnSearch.onclick = function() {
window.alert("You clicked the search button!");
};
divContainer.appendChild(btnSearch);
document.getElementById("divUpperLeft").appendChild(divContainer);
}
addUpperLeftDiv();
includeSearchWidget();