Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Geocoding widget #1157

Merged
merged 59 commits into from
Oct 23, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
b44521a
Semi-functional geocoding widget.
kring Sep 12, 2013
1d93eae
Animate to destination instead of jumping there.
kring Sep 12, 2013
fce2533
Style improvements, make enter submit.
kring Sep 12, 2013
63c7c36
Show resolved name after geocoding.
kring Sep 12, 2013
6e579cd
Cleanup.
kring Sep 12, 2013
0758e5a
Visualize routes between two points.
kring Sep 12, 2013
bb8b727
Update clock to match route.
kring Sep 13, 2013
cd67e54
Put nav routes on terrain. Also temp demo app.
kring Sep 13, 2013
554919e
Add shady depth test toggle.
kring Sep 13, 2013
d8bc6f6
Elimiante some wackyness in the route.
kring Sep 13, 2013
2654aa9
Show a marker instead of a point.
kring Sep 13, 2013
a3f9d83
Move geocoding widget to the top right.
kring Sep 14, 2013
020bbdf
GeocodingWidget doc.
kring Sep 14, 2013
649271f
Move geocoding widget above buttons.
kring Sep 14, 2013
e120201
Merge remote-tracking branch 'origin/bingKey' into geocodingWidget
kring Sep 14, 2013
c9c261f
Clean up use of Bing Maps API.
kring Sep 14, 2013
7909e9b
Merge remote-tracking branch 'origin/master' into geocodingWidget
kring Sep 18, 2013
65c85c0
Merge remote-tracking branch 'origin/bingKey' into geocodingWidget
kring Sep 18, 2013
f5bf367
Rip out route plotting functionality, and some cleanup.
kring Sep 18, 2013
f597cdb
Fix destroy, and add tests.
kring Sep 18, 2013
9958b61
Another test of the GeocodingWidget's viewmodel.
kring Sep 18, 2013
d496ed3
Remove Sandcastle app used for demoing.
kring Sep 18, 2013
d7bc870
Update changes.md.
kring Sep 18, 2013
417010b
Remove unused file.
kring Sep 18, 2013
67517aa
Merge remote-tracking branch 'origin/master' into geocodingWidget
kring Sep 21, 2013
a732c47
Merge remote-tracking branch 'origin/master' into geocodingWidget
kring Sep 26, 2013
b02b481
Merge remote-tracking branch 'origin/master' into geocodingWidget
kring Oct 15, 2013
76414ad
Rename GeocodingWidget to Geocoder.
kring Oct 15, 2013
5654873
Clean up 'enter' handling in geocoder input field.
kring Oct 15, 2013
6a52e86
Indicate when geocoding is in progress, and support canceling.
kring Oct 15, 2013
af3bfea
Remove the delay I added for testing.
kring Oct 15, 2013
232846c
Fix Geocoder.destroy method.
kring Oct 15, 2013
7088f64
Remove no longer applicable test.
kring Oct 15, 2013
b324074
Move changes.md entry to the b22 release.
kring Oct 15, 2013
0ade210
Merge remote-tracking branch 'origin/master' into geocodingWidget
kring Oct 21, 2013
8686c62
Move geocoder into toolbar and make it auto-expand.
emackey Oct 21, 2013
cf4160b
Merge remote-tracking branch 'origin/master' into geocodingWidget
emackey Oct 21, 2013
0a95dc9
Fix 2D/CV geocoding.
kring Oct 21, 2013
61616ba
Update with svgPath changes.
emackey Oct 21, 2013
455ea98
Merge remote-tracking branch 'origin/geocodingWidget' into geocodingW…
emackey Oct 21, 2013
e4cf75b
Try to make sceneModePicker more tolerant of CSS order.
emackey Oct 21, 2013
0d19b3c
Remove the dependency on CesiumWidget.css
emackey Oct 22, 2013
5a204c8
Add lighter.css.
emackey Oct 22, 2013
12372f1
Merge remote-tracking branch 'origin/geocodingWidget' into sceneModeCss
emackey Oct 22, 2013
0aeb7bf
This addresses issue #1255.
emackey Oct 22, 2013
00e8824
CSS margin consistency.
emackey Oct 22, 2013
e4e87fc
Optimize the `left: 0` case of sliding SVG in sceneModePicker.
emackey Oct 22, 2013
298dad5
Merge pull request #1258 from AnalyticalGraphicsInc/sceneModeCss
mramato Oct 22, 2013
ea95c01
Merge branch 'master' into geocodingWidget
mramato Oct 22, 2013
2e803ca
Updates after review
mramato Oct 23, 2013
f503dd7
Workaroud apparent knockout bug
mramato Oct 23, 2013
d670d2c
Add missing Geocoder specs to Viewer and fix issues it uncovered.
mramato Oct 23, 2013
c3023c5
Viewer.destroy needs to destroy the Geocoder.
mramato Oct 23, 2013
777488e
Flesh out unit tests, fix uncovered bugs.
mramato Oct 23, 2013
41132ab
Improve focus handling.
mramato Oct 23, 2013
0ab0bed
Make sure `searchText` is always a string, fix specs.
mramato Oct 23, 2013
2d4386b
Make the CSS a bit clearer. No change to functionality.
emackey Oct 23, 2013
7e3e47f
Fix jsDoc.
mramato Oct 23, 2013
67ce49e
Fix clicking button to search.
mramato Oct 23, 2013
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ Beta Releases
* Added `Primitive.allowPicking` to save memory when picking is not needed.
* Added `debugShowBoundingVolume`, for debugging primitive rendering, to `Primitive`, `Polygon`, `ExtentPrimitive`, `EllipsoidPrimitive`, `BillboardCollection`, `LabelCollection`, and `PolylineCollection`.
* Added `DebugModelMatrixPrimitive` for debugging primitive's `modelMatrix`.
* Added a `Geocoder` widget that allows users to enter an address or the name of a landmark and zoom the camera to that location. It is enabled by default in applications that use the `Viewer` widget.

### b21 - 2013-10-01

Expand Down
2 changes: 1 addition & 1 deletion Source/Widgets/BaseLayerPicker/BaseLayerPicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ define([

var element = this._element = document.createElement('button');
this._element.type = 'button';
this._element.className = 'cesium-widget-button cesium-widget-small-icon';
this._element.className = 'cesium-widget-button cesium-widget-toolbar-icon';
this._element.setAttribute('data-bind', 'attr: { title: selectedName }, click: toggleDropDown');
container.appendChild(this._element);

Expand Down
10 changes: 1 addition & 9 deletions Source/Widgets/CesiumWidget/CesiumWidget.css
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
cursor: default;
}

.cesium-widget-small-icon {
.cesium-widget-toolbar-icon {
box-sizing: border-box;
width: 32px;
height: 32px;
Expand All @@ -81,14 +81,6 @@
z-index: 0; /* Workaround for rounded raster image corners in Chrome */
}

.cesium-widget-vertical-icon {
box-sizing: border-box;
width: 32px;
height: 32px;
padding: 0;
margin: 3px 0;
}

.cesium-widget-errorPanel {
position: absolute;
top: 0;
Expand Down
2 changes: 1 addition & 1 deletion Source/Widgets/FullscreenButton/FullscreenButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ define([

this._element = document.createElement('button');
this._element.type = 'button';
this._element.className = 'cesium-widget-button cesium-widget-small-icon cesium-fullscreenButton';
this._element.className = 'cesium-widget-button cesium-fullscreenButton';
this._element.setAttribute('data-bind', '\
attr: { title: tooltip },\
click: command,\
Expand Down
45 changes: 45 additions & 0 deletions Source/Widgets/Geocoder/Geocoder.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
.cesium-geocoder-input {
border: solid 1px #888;
background-color: rgba(40, 40, 40, 0.7);
color: white;
display: inline-block;
vertical-align: middle;
width: 0;
padding-right: 32px;
height: 32px;
padding-top: 0px;
padding-bottom: 0px;
opacity: 0.55;
-webkit-transition: width ease-in-out 0.25s, opacity ease-in-out 0.25s;
-moz-transition: width ease-in-out 0.25s, opacity ease-in-out 0.25s;
transition: width ease-in-out 0.25s, opacity ease-in-out 0.25s;
}

.cesium-viewer-geocoderContainer:hover .cesium-geocoder-input {
border-color: #aef;
box-shadow: 0 0 8px #fff;
}

.cesium-viewer-geocoderContainer:hover .cesium-geocoder-input,
.cesium-viewer-geocoderContainer .cesium-geocoder-input:focus,
.cesium-viewer-geocoderContainer .cesium-geocoder-input-wide {
padding-left: 4px;
width: 250px;
opacity: 1;
}

.cesium-geocoder-goButton {
display: inline-block;
position: absolute;
cursor: pointer;
width: 32px;
top: 1px;
right: 1px;
height: 32px;
vertical-align: middle;
fill: #edffff;
}

.cesium-geocoder-goButton:hover {
background-color: rgba(76, 142, 184, 0.8);
}
158 changes: 158 additions & 0 deletions Source/Widgets/Geocoder/Geocoder.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
/*global define*/
define([
'../../Core/defined',
'../../Core/defineProperties',
'../../Core/destroyObject',
'../../Core/DeveloperError',
'../SvgPath/SvgPath',
'../getElement',
'./GeocoderViewModel',
'../../ThirdParty/knockout'
], function(
defined,
defineProperties,
destroyObject,
DeveloperError,
SvgPath,
getElement,
GeocoderViewModel,
knockout) {
"use strict";

var startSearchPath = 'M29.772,26.433l-7.126-7.126c0.96-1.583,1.523-3.435,1.524-5.421C24.169,8.093,19.478,3.401,13.688,3.399C7.897,3.401,3.204,8.093,3.204,13.885c0,5.789,4.693,10.481,10.484,10.481c1.987,0,3.839-0.563,5.422-1.523l7.128,7.127L29.772,26.433zM7.203,13.885c0.006-3.582,2.903-6.478,6.484-6.486c3.579,0.008,6.478,2.904,6.484,6.486c-0.007,3.58-2.905,6.476-6.484,6.484C10.106,20.361,7.209,17.465,7.203,13.885z';
var stopSearchPath = 'M24.778,21.419 19.276,15.917 24.777,10.415 21.949,7.585 16.447,13.087 10.945,7.585 8.117,10.415 13.618,15.917 8.116,21.419 10.946,24.248 16.447,18.746 21.948,24.248z';

/**
* A widget for finding addresses and landmarks, and flying the camera to them. Geocoding is
* performed using the <a href="http://msdn.microsoft.com/en-us/library/ff701715.aspx">Bing Maps Locations API</a>.
*
* @alias Geocoder
* @constructor
*
* @param {Element|String} description.container The DOM element or ID that will contain the widget.
* @param {Scene} description.scene The Scene instance to use.
* @param {String} [description.url='http://dev.virtualearth.net'] The base URL of the Bing Maps API.
* @param {String} [description.key] The Bing Maps key for your application, which can be
* created at <a href='https://www.bingmapsportal.com/'>https://www.bingmapsportal.com/</a>.
* If this parameter is not provided, {@link BingMapsApi.defaultKey} is used.
* If {@link BingMapsApi.defaultKey} is undefined as well, a message is
* written to the console reminding you that you must create and supply a Bing Maps
* key as soon as possible. Please do not deploy an application that uses
* this widget without creating a separate key for your application.
* @param {Ellipsoid} [description.ellipsoid=Ellipsoid.WGS84] The Scene's primary ellipsoid.
* @param {Number} [description.flightDuration=1500] The duration of the camera flight to an entered location, in milliseconds.
*
* @exception {DeveloperError} description.container is required.
* @exception {DeveloperError} description.scene is required.
*/
var Geocoder = function(description) {
if (!defined(description) || !defined(description.container)) {
throw new DeveloperError('description.container is required.');
}
if (!defined(description.scene)) {
throw new DeveloperError('description.scene is required.');
}

var container = getElement(description.container);
var form = document.createElement('form');
form.setAttribute('data-bind', 'submit: search');

var textBox = document.createElement('input');
textBox.type = 'text';
textBox.className = 'cesium-geocoder-input';
textBox.setAttribute('placeholder', 'Enter an address or landmark...');
textBox.setAttribute('data-bind', 'value: searchText, valueUpdate: "afterkeydown", css: { "cesium-geocoder-input-wide" : searchText.length > 0 }');
form.appendChild(textBox);

var goButton = document.createElement('span');
goButton.className = 'cesium-geocoder-goButton';
goButton.setAttribute('data-bind', 'click: search');
form.appendChild(goButton);

container.appendChild(form);

this._container = container;
this._viewModel = new GeocoderViewModel(description);
this._form = form;
this._svgPath = new SvgPath(goButton, 32, 32, startSearchPath);
knockout.applyBindings(this._viewModel, this._container);

var that = this;
this._subscription = knockout.getObservable(this._viewModel, 'isSearchInProgress').subscribe(function(isSearchInProgress) {
that._svgPath.path = isSearchInProgress ? stopSearchPath : startSearchPath;
});

this._onInputBegin = function(e) {
if (!container.contains(e.target)) {
textBox.blur();
}
};

this._onInputEnd = function(e) {
if (container.contains(e.target)) {
textBox.focus();
}
};

//We subscribe to both begin and end events in order to give the text box
//focus no matter where on the widget is clicked.
document.addEventListener('mousedown', this._onInputBegin, true);
document.addEventListener('mouseup', this._onInputEnd, true);
document.addEventListener('touchstart', this._onInputBegin, true);
document.addEventListener('touchend', this._onInputEnd, true);
};

defineProperties(Geocoder.prototype, {
/**
* Gets the parent container.
* @memberof Geocoder.prototype
*
* @type {Element}
*/
container : {
get : function() {
return this._container;
}
},

/**
* Gets the view model.
* @memberof Geocoder.prototype
*
* @type {GeocoderViewModel}
*/
viewModel : {
get : function() {
return this._viewModel;
}
}
});

/**
* @memberof Geocoder
* @returns {Boolean} true if the object has been destroyed, false otherwise.
*/
Geocoder.prototype.isDestroyed = function() {
return false;
};

/**
* Destroys the widget. Should be called if permanently
* removing the widget from layout.
* @memberof Geocoder
*/
Geocoder.prototype.destroy = function() {
document.removeEventListener('mousedown', this._onInputBegin, true);
document.removeEventListener('mouseup', this._onInputEnd, true);
document.removeEventListener('touchstart', this._onInputBegin, true);
document.removeEventListener('touchend', this._onInputEnd, true);
this._subscription.dispose();

var container = this._container;
knockout.cleanNode(container);
container.removeChild(this._form);
return destroyObject(this);
};

return Geocoder;
});
Loading