Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sandcastle.addToolbarButton('Search', function() {
- var dataSource2 = new Cesium.GeoJsonDataSource();
- var promise = dataSource2.load('Apps/SampleData/Buildings.geojson');
- promise.then(function(dataSource2) {
- viewer.dataSources.add(dataSource2);
- //viewer.zoomTo(dataSource2);
- //Get the array of entities
- var entities2 = dataSource2.entities.values;
- var colorHash = {};
- for (var i = 0; i < entities2.length; i++) {
- //For each entity, create a random color based on the state name.
- //Some states have multiple entities, so we store the color in a
- //hash so that we use the same color for the entire state.
- var entity = entities2[i];
- var name = entity.Height;
- var color = colorHash[name];
- if (!color) {
- color = Cesium.Color.BROWN;
- colorHash[name] = color;
- }
- //Set the polygon material to our random color.
- entity.polygon.material = color;
- //Remove the outlines.
- entity.polygon.outline = false;
- entity.polygon.extrudedHeight = entity.properties.Height;
- }
- for (var x=0; x<entities2.length; x++) {
- var name = entities2[x].properties.Name.toLowerCase();
- var textbox_value = document.getElementById("search").value.toLowerCase();
- var textbox_value_array = [];
- textbox_value_array.push(textbox_value);
- if (jQuery.inArray(name, textbox_value_array) > -1) {
- viewer.flyTo(entities2[x]);
- }
- }
- });
- });
- Sandcastle.addToolbarButton('3D View', function() {
- //Seed the random number generator for repeatable results.
- Cesium.Math.setRandomNumberSeed(0);
- var dataSource1 = new Cesium.GeoJsonDataSource();
- var roads = dataSource1.load('Apps/SampleData/Roads_Vishak.geojson');
- roads.then(function(dataSource1) {
- viewer.dataSources.add(dataSource1);
- //viewer.zoomTo(dataSource1);
- //Get the array of entities
- var entities1 = dataSource1.entities.values;
- var colorHash = {};
- for (var i = 0; i < entities1.length; i++) {
- //For each entity, create a random color based on the state name.
- //Some states have multiple entities, so we store the color in a
- //hash so that we use the same color for the entire state.
- var entity = entities1[i];
- var name = entity.properties.highway;
- var color = colorHash[name];
- if (!color) {
- color = Cesium.Color.SNOW;
- colorHash[name] = color;
- }
- //Set the polygon material to our random color.
- entity.polyline.material = color;
- //Remove the outlines.
- entity.polyline.outline = false;
- //entity.polyline.translucent = true;
- }
- }).otherwise(function(error){
- //Display any errrors encountered while loading.
- window.alert(error);
- });
- /*var dataSource2 = new Cesium.GeoJsonDataSource();
- var positions = []; // xy position array
- var promise = dataSource2.load('Apps/SampleData/Region_Point.geojson');
- promise.then(function(dataSource2) {
- viewer.dataSources.add(dataSource2);
- //viewer.zoomTo(dataSource2);
- //Get the array of entities
- var entities2 = dataSource2.entities.values;
- var colorHash = {};
- for (var i = 0; i < entities2.length; i++) {
- //For each entity, create a random color based on the state name.
- //Some states have multiple entities, so we store the color in a
- //hash so that we use the same color for the entire state.
- var entity = entities2[i];
- entity.billboard = undefined;
- entity.point = new Cesium.PointGraphics({
- color: Cesium.Color.RED,
- pixelSize: 10
- });
- }
- }).otherwise(function(error){
- //Display any errrors encountered while loading.
- window.alert(error);
- });*/
- var dataSource3 = new Cesium.GeoJsonDataSource();
- var promise = dataSource3.load('Apps/SampleData/Buildings.geojson');
- promise.then(function(dataSource3) {
- viewer.dataSources.add(dataSource3);
- viewer.zoomTo(dataSource3);
- //Get the array of entities
- var entities3 = dataSource3.entities.values;
- var colorHash = {};
- for (var i = 0; i < entities3.length; i++) {
- var entity = entities3[i];
- var name = entity.properties.Height;
- var color = colorHash[name];
- if (!color) {
- color = Cesium.Color.BROWN;
- colorHash[name] = color;
- }
- //Set the polygon material to our random color.
- entity.polygon.material = color;
- //Remove the outlines.
- entity.polygon.outline = false;
- entity.polygon.extrudedHeight = entity.properties.Height;
- }
- }).otherwise(function(error){
- //Display any errrors encountered while loading.
- window.alert(error);
- });
- });
Add Comment
Please, Sign In to add comment