Created
August 14, 2015 16:34
-
-
Save mramato/c0bc4337fae76751970b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var viewer = new Cesium.Viewer('cesiumContainer'); | |
//Normally you would define the default styles | |
//in CSS, but for the example it's easier to | |
//just do it here. | |
var geoOverlay = document.createElement('div'); | |
viewer.container.appendChild(geoOverlay); | |
geoOverlay.style.display = 'none'; | |
geoOverlay.style['background-color'] = 'white'; | |
geoOverlay.style.position = 'absolute'; | |
geoOverlay.style.top = '0'; | |
geoOverlay.style.left = '0'; | |
geoOverlay.style.width = '20px'; | |
geoOverlay.style.height = '20px'; | |
geoOverlay.style['pointer-events'] = 'none'; //Disable mouse inter | |
//The geolocation that we want to the element t olive. | |
var anchor = Cesium.Cartesian3.fromDegrees(0, 0, 0); | |
//Every frame, figure out if the geolocation is on the screen | |
//and move the element accordingly. | |
var tmp = new Cesium.Cartesian2(); | |
viewer.scene.preRender.addEventListener(function(){ | |
var result = Cesium.SceneTransforms.wgs84ToWindowCoordinates(viewer.scene, anchor, tmp); | |
if(Cesium.defined(result)){ | |
geoOverlay.style.display = 'block'; | |
geoOverlay.style.top = tmp.y + 'px'; | |
geoOverlay.style.left = tmp.x + 'px'; | |
} else { | |
geoOverlay.style.display = 'none'; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment