So, my idea of turning off the Geolocation functionality in an Openlayers 3.9.0 map is to have a toggle button that when is clicked it stops the tracking and removes the feature from the geolocation layer
geolocation.setTracking('false');
featuresOverlay.getSource().clear();
and then to turn it on again it turns the tracking on, adds a feature to the geolocation layer, sets its coordinates and re-centers the map
geolocation.setTracking('true');
featuresOverlay.getSource().addFeature(positionFeature);
var coordinates = geolocation.getPosition();
positionFeature.setGeometry(coordinates ? new ol.geom.Point(coordinates) : null);
view.setCenter(coordinates);
Well, this technically does not count as turning on/off the geolocation because it removes all the visual elements, it does not actually turns on/off the API. Is there such a possibility, or the above are enough?
Sure it does, after one minor change.
Assuming that geolocation in your code references an instance of ol.Geolocation, calling geolocation.setTracking(false) will make the geolocation call clearWatch on the browsers geolocation API. The relevant code is here.
However, setTracking expects a boolean value. You send the string 'false', which is interpreted as a truthy value (since it's a non-empty string). Remove the quotation marks from the setTracking paramters, and it should work as expected.
Related
I'm trying to configure the C1 and C2 buttons in a custom DJI app. I found that I can call the method setCustomButtonTags:withCompletion, which is part of the DJIRemoteController class.
I tried to fill the DJIRCCustomButtonTags object to provide it as a parameter of the method, but I don't know which values are valid for c1buttontag and c2buttontag. Does anyone knows something about using the setCustomButtonTags method?
Valid values are in range [0, 255] (documentation).
You can set you own values, but it doesn't make the buttons do anything. Instead you could read the values after they are set by DJI's own application, add button listeners, and do some stuff when button state changes.
As far as I know, the values used by DJI's application are not documented anywhere. So you'd have to find out their meaning one by one. And then implement the functionality one by one...
Here is an example (for Android) for implementing button listeners: https://github.com/dji-sdk/Mobile-SDK-Android/issues/286
I was trying to jump around documents on line, and i see the set function for when i do set("myString", "hello"); or set("myMap.test", "world"); but i was curious as to what the inverse is? I figured unset but when looking online at the Properties sections of Polymer 1.0 Dart code, i wasnt quite getting the information I wanted.
What is the inverse of set, to remove an attribute? My particular use case is to remove a key from a map, unset("myMap.testKey");
Since set is defined in Polymer_base.dart, i thought it would rest somewhere within that file, but i did not see any "unset" or similar.
I don't know if it works but I would remove the element from the map and then call
notifyPath('myMap.testKey, null);
If the values was null already then this probably won't work.
I'm implementing a feature for users to select a list item that corresponds to a point on the map. I am currently able to set the correct map center and the zoom level but the map tiles are blank until I cause a MouseWheelZoom interaction to occur on the map. How do I get my WMTS layers to update to the new zoom level and map extent?
In principle, changing the tileUrlFunction of a WMTS source will trigger a refresh, because that clears the tile cache. If you're lucky and your WMTS server makes proper use of Etags, just using the same url function again will work:
wmtsSource.setTileUrlFunction(wmtsSource.getTileUrlFunction());
If your WMTS server just sets expire headers, you'll have to append something to the url to force the browser to refetch it. Assuming you use KVP encoding to talk to your WMTS server, you could achieve this by doing something like
var random = Math.random();
var originalTileUrlFunction = wmtsSource.getTileUrlFunction();
wmtsSource.setTileUrlFunction(function() {
return originalTileUrlFunction.apply(this, arguments) + '&' + random;
});
I'm planning to make an app for ios7, and have an issue with the administrativeArea Placemark Attribute.
For iOS6 i get the full name of the administrative area (ex. "California"), but for the iOS7, I get the value of "CA". This is a problem when its so varying. Is there any way I can control this input so its more consistent?
The apple docs doesnt eigher explain this in details..
http://developer.apple.com/library/mac/documentation/CoreLocation/Reference/CLPlacemark_class/Reference/Reference.html#//apple_ref/occ/instp/CLPlacemark/administrativeArea
Thanks!
You can only parse it to uoy needed value.
I can offer you find the list of administrative areas with full name and with little.
After you can add this in 2 .txt files, import them in project,create 2 NSArrays and initialize each array in cycle.
After you can check administrative area name and return right value.
I'm having a great time playing around with knockout js and have just started to get to grips with adding custom bindingHandlers.
I'm struggling a bit with the update function of a 3rd party jqWidget gauge - I can only get it to animate the first time I update the variable. On each update after that it just sets the value directly.
I don't fully understand ko.utils.registerEventHandler() and what it does although I've seen it in a bunch of other examples. Is this what is causing the animation to break? How do I know which events to register from the 3rd party widget?
For some reason this works fine if I add a jquery ui slider that is also bound to the observable.
You can test this here: set the value a few times to see that it animates the first time and not after that.
http://jsfiddle.net/LkqTU/4531/
When you update the input field, your observable will end up being a string. It looks like the gauge does not like to be updated with a string value, at least after the first time.
So, if you ensure that you are updating it with a number (parseInt, parseFloat, or just + depending on the situation), then it appears to update fine.
Something like:
update: function(element, valueAccessor) {
var gaugeval = parseInt(ko.utils.unwrapObservable(valueAccessor()), 10);
$(element).jqxGauge('value', gaugeval || 0);
}
http://jsfiddle.net/rniemeyer/LkqTU/4532/
You would generally only register event handlers in a scenario like this to react to changes made by a user where you would want to update your view model data. For example, if there was a way for a user to click on the gauge to change the value, then you would want to handle that event and update your view model value accordingly.
I'm answering the
I don't fully understand ko.utils.registerEventHandler() and what it does
part of your question.
registerEventHandler will register your event handler function in a cross-browser compatible way. If you are using jQuery, Knockout will use jQuery's bind function to register the event handler. Otherwise, will use the browser Web API with a consistent behavior across browsers.
You can check it out on the source code.