Skip to content

Commit

Permalink
Merge pull request #5976 from marhab21/reversegeocode
Browse files Browse the repository at this point in the history
Reversegeocode
  • Loading branch information
Hannah authored Nov 29, 2017
2 parents c31f219 + 3f4253a commit ad7636e
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 1 deletion.
108 changes: 108 additions & 0 deletions Apps/Sandcastle/gallery/Reverse Geocoder.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
<meta name="description" content="Attach a custom data source to the geocoder widget.">
<meta name="cesium-sandcastle-labels" content="Tutorials,Showcases">
<title>Cesium Demo</title>
<script type="text/javascript" src="../Sandcastle-header.js"></script>
<script type="text/javascript" src="../../../ThirdParty/requirejs-2.1.20/require.js"></script>
<script type="text/javascript">
if(typeof require === "function") {
require.config({
baseUrl : '../../../Source',
waitSeconds : 120
});
}
</script>
</head>
<body class="sandcastle-loading" data-sandcastle-bucket="bucket-requirejs.html">
<style>
@import url(../templates/bucket.css);
#toolbar {
background: rgba(42, 42, 42, 0.8);
padding: 4px;
border-radius: 4px;
}
#toolbar input {
vertical-align: middle;
padding-top: 2px;
padding-bottom: 2px;
}
</style>
<div id="cesiumContainer" class="fullSize"></div>
<div id="loadingOverlay"><h1>Loading...</h1></div>
<script id="cesium_sandcastle_script">
function startup(Cesium) {
'use strict';
//Sandcastle_Begin
var viewer = new Cesium.Viewer('cesiumContainer');
var camera = viewer.camera;
var ellipsoid = viewer.scene.globe.ellipsoid;

var baseUrl = 'https://dev.virtualearth.net/REST/v1/Locations/';

function setAddressPoint(position, locationAddress, longitudeDegrees, latitudeDegrees ) {
viewer.entities.add({
name : 'Longitude:' + longitudeDegrees.toFixed(4) + ', Latitude: ' + latitudeDegrees.toFixed(4),
position : position,
point : {
pixelSize : 5,
color : Cesium.Color.RED,
outlineColor : Cesium.Color.WHITE,
outlineWidth : 2
},
label : {
text : locationAddress,
font : '14pt monospace',
style: Cesium.LabelStyle.FILL_AND_OUTLINE,
outlineWidth : 2,
verticalOrigin : Cesium.VerticalOrigin.BOTTOM,
pixelOffset : new Cesium.Cartesian2(0, -5)
}
});
}

var handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
handler.setInputAction(function (click) {
var position = camera.pickEllipsoid(click.position);
if (Cesium.defined(position)) {
var cartographic = ellipsoid.cartesianToCartographic(position);
var longitudeDegrees = Cesium.Math.toDegrees(cartographic.longitude);
var latitudeDegrees = Cesium.Math.toDegrees(cartographic.latitude);
var url = baseUrl + latitudeDegrees + "," +longitudeDegrees;
var promise = Cesium.loadJsonp(url, {
parameters : {
key : Cesium.BingMapsApi.getKey()
},
callbackParameterName : 'jsonp'
});

promise.then(function(result) {
var resources = result.resourceSets[0].resources;
if (resources.length === 0) {
return;
}
var locationAddress = resources[0].name;
if (locationAddress.length > 15) {
locationAddress = locationAddress.replace(/, /g, '\n');
}
setAddressPoint(position, locationAddress, longitudeDegrees, latitudeDegrees);
}).otherwise(function(error) {
console.error("ERROR getting address: " + error);
});
}
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
//Sandcastle_End
Sandcastle.finishedLoading();
}
if (typeof Cesium !== "undefined") {
startup(Cesium);
} else if (typeof require === "function") {
require(["Cesium"], startup);
}
</script>
</body>
</html>
Binary file added Apps/Sandcastle/gallery/Reverse Geocoder.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ Change Log

### 1.40 - 2017-12-01

* Added `Globe.material` to apply materials to the globe/terrain for shading such as height- or slope-based color ramps. See the new [Sandcastle example](https://cesiumjs.org/Cesium/Apps/Sandcastle/?src=Globe%20Materials.html&label=Showcases). [#5919](https://github.com/AnalyticalGraphicsInc/cesium/pull/5919/files)
* Added a Reverse Geocoder based on the Bing Maps API as a Sandcastle demo. [#5976](https://github.com/AnalyticalGraphicsInc/cesium/pull/5976)
* Added `Globe.material` to apply materials to the globe/terrain for shading such as height- or slope-based color ramps. See the new [Sandcastle example](https://cesiumjs.org/Cesium/Apps/Sandcastle/?src=Globe%20Materials.html&label=Showcases). [#5919](https://github.com/AnalyticalGraphicsInc/cesium/pull/5919/fil
* Added ability to support touch event in Imagery Layers Split demo application. [#5948](https://github.com/AnalyticalGraphicsInc/cesium/pull/5948)
* Added `file:` scheme compatibility to `joinUrls`. [#5989](https://github.com/AnalyticalGraphicsInc/cesium/pull/5989)
* Fixed `Invalid asm.js: Invalid member of stdlib` console error by recompiling crunch.js with latest emscripten toolchain. [#5847](https://github.com/AnalyticalGraphicsInc/cesium/issues/5847)
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu
* [M.Eng. René Schwarz](https://github.com/DigNative)
* [Gilles Cébélieu (IGN France)](https://github.com/gcebelieu)
* [Guillaume Beraudo](https://github.com/gberaudo)
* [Martine Habib](https://github.com/marhab21)
* [Thomas Hirsch](https://github.com/relet)
* [Ayush Khandelwal](https://github.com/ayk115)
* [Aditya Raisinghani](https://github.com/adi2412)
Expand Down

0 comments on commit ad7636e

Please sign in to comment.