-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Allow custom parameters in the template url of an UrlTemplateImageryP… #5696
Changes from 2 commits
e726b0d
8566cf2
26ec8de
2ed8e9f
d6abaf1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -132,6 +132,7 @@ define([ | |
* source does not support picking features or if you don't want this provider's features to be pickable. Note | ||
* that this can be dynamically overridden by modifying the {@link UriTemplateImageryProvider#enablePickFeatures} | ||
* property. | ||
* @param {Object} [options.customTags] Allow to replace custom keywords in the URL template. The object must have strings as keys and functions as values. | ||
* | ||
* | ||
* @example | ||
|
@@ -157,6 +158,15 @@ define([ | |
* 'width=256&height=256', | ||
* rectangle : Cesium.Rectangle.fromDegrees(96.799393, -43.598214999057824, 153.63925700000001, -9.2159219997013) | ||
* }); | ||
* // Using custom tags in your template url. | ||
* var custom = new Cesium.UrlTemplateImageryProvider({ | ||
* url : 'https://yoururl/{Time}/{z}/{y}/{x}.png', | ||
* customTags : { | ||
* Time: function(imageryProvider, x, y , level) { | ||
* return '20171231' | ||
* } | ||
* } | ||
* }); | ||
* | ||
* @see ArcGisMapServerImageryProvider | ||
* @see BingMapsImageryProvider | ||
|
@@ -568,6 +578,16 @@ define([ | |
} | ||
that._credit = credit; | ||
|
||
if (defined(properties.customTags)) { | ||
for (var tag in properties.customTags) { | ||
if (properties.customTags.hasOwnProperty(tag)) { | ||
var targetTag = '{' + tag + '}'; | ||
tags[targetTag] = properties.customTags[tag]; //eslint-disable-line no-use-before-define | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm surprised these eslint directives are needed. What does it thing is being used before define? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here was the messages:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's remove the directives and simple move There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just realized there is a major issue here. Since There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
pickFeaturesTags[targetTag] = properties.customTags[tag]; //eslint-disable-line no-use-before-define | ||
} | ||
} | ||
} | ||
|
||
that._urlParts = urlTemplateToParts(that._url, tags); //eslint-disable-line no-use-before-define | ||
that._pickFeaturesUrlParts = urlTemplateToParts(that._pickFeaturesUrl, pickFeaturesTags); //eslint-disable-line no-use-before-define | ||
return true; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a general rule, we try to keep property access to a minimum, rather than have
properties.customTags
multiple times, extract avar customTags = properties.customTags
variable and use it throughout.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok