-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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 zoom to extent control #824
Conversation
Do you have the closure_linter package installed and gjslint available on your PATH? See https://developers.google.com/closure/utilities/docs/linter_howto. |
Thanks, than I will fix the errors :-) |
Tests pass than it's ready to review :-) |
<div class="row-fluid"> | ||
|
||
<div class="span4"> | ||
<h4 id="title">Scale line example</h4> |
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.
This should be "Navigation controls example".
Oups I just see that it's not working on Chromium ... I will fix it :-) |
I just drop the cache to make it working ... |
I update the example page (should be a fixup before merging !) |
More generally; do we want/need this control? diff --git a/examples/simple.html b/examples/simple.html
index 5891875..6611499 100644
--- a/examples/simple.html
+++ b/examples/simple.html
@@ -40,6 +40,7 @@
<p id="shortdesc">Example of a simple map.</p>
<div id="docs">
<p>See the <a href="simple.js" target="_blank">simple.js source</a> to see how this is done.</p>
+ <button id="max-extent" class="btn">zoom to max extent</button>
</div>
<div id="tags">simple, openstreetmap</div>
</div>
diff --git a/examples/simple.js b/examples/simple.js
index b1335ef..920d00d 100644
--- a/examples/simple.js
+++ b/examples/simple.js
@@ -18,3 +18,7 @@ var map = new ol.Map({
zoom: 2
})
});
+
+document.getElementById('max-extent').addEventListener('click', function() {
+ map.getView().fitExtent([813079, 848966, 5929220, 5936863], map.getSize());
+}); |
@sbrunner, thanks it was indeed a stale stylesheet in my browser cache. I've checked the example Chrome, Firefox and Safari on Mac OS X and all work as expected. @fredj, even those the same effect can be achieved in a few lines of code, I think it's worth including this control in the core of ol3. It's a few lines of code less for users to write, and is properly integrated into ol3's control architecture. With the Closure Compiler/build system, if you don't use it you don't pay for it, so it doesn't have any negative effect on the build size. |
LGTM |
Having a look right now. |
@@ -0,0 +1,2 @@ | |||
@exportClass ol.control.ZoomToExtent ol.control.ZoomToExtentOptions | |||
@exportProperty ol.control.ZoomToExtent.prototype.setMap |
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.
controls.exports already exports setMap, so it shouldn't be needed here.
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.
I haven't tested, but I think that, due to the way exports work, it is necessary to re-export overridden methods.
My understand is that exporting really creates an alias:
Base.prototype.mangledMethod = function () { /* implementation */ };
// export then does
Base.prototype.exportedMethod = Base.prototype.mangledMethod
In this case, calling exportedMethod
on an instance of a child class will actually give you the base class's implementation since it's the only method of that name in the instance's prototype chain.
Corrections welcome.
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.
I think you're absolutely correct on that.
I agree. And styling |
Yes, I already plan to merge them
Yes, do you have a quick input of how to do it ?
It's because I plan to create only one example for 'Zoom to extent', 'Zoom to position' and 'Pan buttons'. If it's not a good idea I can do one example per control ... |
To reset the rotation, call
As @elemoine suggests, it makes sense to replace the custom controls example with a different control, but I think it's OK to do this in a separate pull request. Having a single example showing several navigation controls makes sense to me. |
Ok. Didn't know that was your intent. |
Yes. |
Thanks, I will modify the custom-controls example, is it OK if I steal have one commit for the control and the example ? |
I'd personally do two commits: one for the control and one for the example. Easy to do:
|
I think that I take care on all your comment :-) |
'title': goog.isDef(options.title) ? options.title : | ||
'Zoom to initial extent' | ||
}); | ||
goog.dom.appendChild(element, button); |
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.
The button is still a div instead of an anchor. You didn't want to change that?
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.
I don't understand why we create an anchor ant transom it (especially with css) to a div, is it needed for accessibility ?
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.
We don't transform it to a div. Please look at the zoom control.
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.
I see:
.ol-zoom a {
display: block;
text-decoration: none;
color: white;
}
and
// prevent #zoomIn anchor from getting appended to the url
browserEvent.preventDefault();
Every (as I know) specific thing of an anchor are removed => div (from me) !
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.
In case it's not clear: by anchor I mean a <a>
element here. See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a.
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.
Phone call => it's for accessibility :-)
if (goog.isDef(options.html)) { | ||
var inner = goog.dom.htmlToDocumentFragment(options.html); | ||
goog.dom.appendChild(button, inner); | ||
} |
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.
The zoom control has no html option. The content is set with CSS.
Shouldn't we create a generic CSS class like .ol-buttons-group for the control buttons ?
|
I remove move my last commit in the https://github.com/sbrunner/ol3/compare/button-class branch, than for me this pull request is ready to merge :-) |
var button = goog.dom.createDom(goog.dom.TagName.A, { | ||
'href': '#zoomExtent', | ||
'title': goog.isDef(options.title) ? options.title : | ||
'Zoom to initial extent' |
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.
"Zoom to initial extent" is not correct. There's no notion of "initial extent". I'd remove "title" entirely for now.
Thanks @elemoine, removed |
@fredj branch updated https://github.com/sbrunner/ol3/compare/control_button (depends on this pull request) |
It looks good. I just added a few more comments, which I will address myself (@sbrunner is on vacation). |
Replaced by #859 |
I create an example page named navigation-controls to have a common example for 'Zoom to extent', 'Zoom to position' and 'Pan buttons'.
----------------------------------------- Solved -----------------------------------------
I try
./build.py check
and./build.py integration-test
, but I have an exception:But I have the same exception on master...