client.vwf.yaml 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. # Copyright 2012 United States Government, as represented by the Secretary of Defense, Under
  2. # Secretary of Defense (Personnel & Readiness).
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
  5. # in compliance with the License. You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software distributed under the License
  10. # is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
  11. # or implied. See the License for the specific language governing permissions and limitations under
  12. # the License.
  13. ## The component representation of a cesium client
  14. ##
  15. ## @name client.vwf
  16. ## @namespace
  17. ---
  18. extends: http://vwf.example.com/client.vwf
  19. properties:
  20. longitude:
  21. latitude:
  22. location:
  23. set: |
  24. this.updateMarkers && this.updateMarkers( value );
  25. this.location = value;
  26. color:
  27. methods:
  28. createMarkers:
  29. updateMarkers:
  30. scripts:
  31. - |
  32. this.initialize = function() {
  33. console.info( "=============== cesium.client.initialize ===============" );
  34. this.billboard = undefined;
  35. this.label = undefined;
  36. }
  37. this.createMarkers = function( requestLocation ) {
  38. var self = this;
  39. var bbDef = {
  40. "extends": "http://vwf.example.com/cesium/billboard.vwf",
  41. };
  42. var lblDef = {
  43. "extends": "http://vwf.example.com/cesium/label.vwf",
  44. };
  45. var scene = self.parent;
  46. while( scene.parent.parent ) {
  47. scene = scene.parent;
  48. }
  49. // this node, nor it's parent are represented in the cesium driver,
  50. // so the scene must be used to add this child
  51. scene.children.create( self.displayName + "-bb", bbDef, function( child ) {
  52. self.billboard = child;
  53. child.position = self.location;
  54. console.info(child.position);
  55. child.color = self.color;
  56. } );
  57. scene.children.create( self.displayName + "-label", lblDef, function( child ) {
  58. self.label = child;
  59. child.position = self.location;
  60. child.fillColor = self.color;
  61. child.verticalOrigin = 'top';
  62. child.horizontalOrigin = 'center';
  63. child.pixelOffset = [ 0, 10, 0 ];
  64. child.font = '18px Helvetica';
  65. child.text = self.displayName;
  66. } );
  67. }
  68. this.updateMarkers = function( pos ) {
  69. if ( this.billboard ) {
  70. this.billboard.position = pos;
  71. }
  72. if ( this.label ) {
  73. this.label.position = pos;
  74. }
  75. } //@ sourceURL = cesium.client.vwf