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

Add optional custom geocoder callback function #6915

Merged
merged 5 commits into from
Aug 14, 2018
Merged

Conversation

hpinkos
Copy link
Contributor

@hpinkos hpinkos commented Aug 13, 2018

Adds the ability to pass a custom callback function to the Geocoder to make it have custom behavior on a successful geocode. If one isn't provided, the default is still to fly to the destination.

Also cleaned up the use of spy functions in the specs.

@hpinkos hpinkos requested a review from mramato August 13, 2018 21:10
@cesium-concierge
Copy link

Thanks for the pull request @hpinkos!

  • ✔️ Signed CLA found.
  • CHANGES.md was not updated.
    • If this change updates the public API in any way, please add a bullet point to CHANGES.md.

Reviewers, don't forget to make sure that:

  • Cesium Viewer works.
  • Works in 2D/CV.
  • Works (or fails gracefully) in IE11.

I am a bot who helps you make Cesium awesome! Contributions to my configuration are welcome.

🌍 🌎 🌏

@@ -34,6 +34,7 @@ define([
* @param {GeocoderService[]} [options.geocoderServices] The geocoder services to be used
* @param {Boolean} [options.autoComplete = true] True if the geocoder should query as the user types to autocomplete
* @param {Number} [options.flightDuration=1.5] The duration of the camera flight to an entered location, in seconds.
* @param {Geocoder~DestinationFoundFunction} [options.destinationFound] A callback function that is called after a successful geocode. If not supplied, the default behavior is to fly the camera to the result destination.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused about the use case here. If a user needs to geocode and then do something with the results, they should just be calling the underlying Geocoder service directly. Why would they be using the Geocoder widget if they didn't want to fly to the destination (which is the main point of the widget)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's useful to be able to use the UI without necessarily imposing the flyto behavior. For example, say I wanted to use the search box to add billboards at certain addresses on the globe.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, thanks.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps expose GeocoderViewModel.flyToDestination as a documented function and assign it as the default value here so that it's more obvious that changing it to something else will remove that functionality? I think that would work better than trying to explain it in that last sentence.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, does it make sense for this to be a Command? It's not called through the knockout bindings right? If that's the case a simple function callback makes more sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, what I meant was does it make sense for this.destinationFoundCommand to be a command at all? Why not just have it stay a callback function?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh gotcha. Yeah, I'll change it

@mramato
Copy link
Contributor

mramato commented Aug 14, 2018

Update CHANGES

@mramato
Copy link
Contributor

mramato commented Aug 14, 2018

I'll look at this in full later today.

@hpinkos
Copy link
Contributor Author

hpinkos commented Aug 14, 2018

@mramato updated CHANGES

@mramato
Copy link
Contributor

mramato commented Aug 14, 2018

I think those are the only other commends I have. Thanks @hpinkos

@hpinkos hpinkos changed the title Add optional custom geocoder command Add optional custom geocoder callback function Aug 14, 2018
@hpinkos
Copy link
Contributor Author

hpinkos commented Aug 14, 2018

@mramato ready for another look

@mramato
Copy link
Contributor

mramato commented Aug 14, 2018

Thanks again.

@mramato mramato merged commit 8fa64c1 into master Aug 14, 2018
@mramato mramato deleted the geocoder-command branch August 14, 2018 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants