Gmaps v3 remove and dispose MVCObject - google-maps-api-3

What is the better way to remove and dispose one MVCObject including unbinds and clearing all events and markers ?. I have tried clearing markers and unbindAll() but the object is not removed of the map. Try with this sample
Thanks.

I think you might not have the right understanding of the MVCObject.
But if you implement a OverlayView which is a MVCObject then to remove it from a map you need to call setMap(null); and then if you expose a onRemove function that will be called and in that you can clean up all your events.
Is that what you were looking for?

Related

Refresh feature with Openlayers 3

Is it possible to refresh a single feature of a vector layer with Openlayers 3? I don't want to refresh all the layer.
If you have a reference to the feature, you can update aspects of the feature like it's geometry or properties and that will be updated in the map.
setGeomtry and setProperties both fire events that make the map update:
http://openlayers.org/en/latest/apidoc/ol.Feature.html
As long as you have set things up so that you can find or keep a direct reference to the feature, you can use the methods detailed in http://openlayers.org/en/latest/apidoc/ol.Feature.html to update a feature
If you are using the ol vector source, you can try to remove the feature and add it again. The Add Feature function triggers a change event (for the whole source, but this shouldn't update already drawed features).
ol.source.Vector.prototype.addFeature = function(feature) {
this.addFeatureInternal(feature);
this.changed();
};

firebase ios gooffline remove observers

Simple question:
Will all obersvers automatically removed when I use goOffline (disconnect to firebase) ?
If not, is there another way to do it, because removeAllOberserves doesn't seem to work or must I keep an array of single handles?
UPDATE
I answer myself.
removeAllOberserves works well, if you call it with the reference you used to set the observer!
Example:
Firebase *userThreadRef;
userThreadRef = [userRef appendPathComponent: ThreadsPath];
[userThreadRef observeEventType: FEventTypeChildAdded withBlock: ^(FDataSnapshot *snapshot) {
...
}];
....
[userThreadRef removeAllObservers];
Do not use a new reference like this:
Firebase *newUserThreadRef = [userRef appendPathComponent: ThreadsPath];
[newUserThreadRef removeAllObservers];
Will all observers automatically removed when I use goOffline (disconnect to firebase) ?
No. Calling goOffline() will not automatically remove observers/listeners.
is there another way to do it, because removeAllOberserves doesn't seem to work or must I keep an array of single handles?
It's hard to say without seeing your code, but likely your expectations are just wrong.
You'll need to call removeAllObservers() on each reference. The All in the method name is for the fact that it removes the observers for all event types, not for all references.

Call function when google map loads

I'm using the basic initialize function from the Google Maps Developer pages. I'm a little new to using maps but I'm managed to achieve what I want from reading the developer site. What I can't find though is a way to call a function once initialize has LOADED the map. For example, I want to update directions based on values in pre-filled forms
I tried something like this...
google.maps.event.addDomListener(window, 'load', function() {
initialize();
updateDirections();
});
Initialize loads the map, updateDirections is the function I want to call to put in directions and some other little things to do with my webpage, but my guess is that maps needs a little time to load, then I should call updateDirections().
How is the best way to do this? I would have thought a callback or onsucess parameter in map options would have been available.
Anyway I think what I'm trying to do is really straight forward but maybe I'm wrong, or maybe it is and I'm just searching for the wrong things. I'm sure it's been answered previously, but I can't seem to find anything that simply does what I'm trying to do.
Thanks
Bizt
Inside your initialize() function, after you create the map and have a reference to it in a variable called map, add an event listener for the idle event:
google.maps.event.addListenerOnce( map, 'idle', function() {
updateDirections();
});
If the only thing you need to do there is call your updateDirections() function, you could just use it directly as the idle callback:
google.maps.event.addListenerOnce( map, 'idle', updateDirections );
Note the use of addListenerOnce() instead of addListener(), so this event listener is only called the first time the event fires. If you used addListener() it would fire every time the map is panned or zoomed.

How do I make one of a stub's method call the real method in ASMock?

In flex I want to do something similar to the following
var audioPlayerMock:AudioPlayer = AudioPlayer(mockRepository.createStub(mockRepository.createStub(AudioPlayer));
SetupResult.forCall(audioPlayerMock.play).(CALL_ACTUAL_PLAY_METHOD(WITH_ARGUMENT));
AudioPlayer has a lot of methods that I want stubbed, (so I use mockRepository.creatStub()). But there is one method, play(), that I want to call the actual actual method (super.play(argument) if my thinking is right). I'm not sure how to do this?
I know I can use createDynamic(AudioPlayer) then stub out every other method, but that is a bit tedious.
Cheers
You can use IMethodOptions.callOriginalMethod() to call the actual implementation on a stubbed class:
SetupResult.forCall(authatoPlayerMock.play(null))
.ignoreArguments()
.callOriginalMethod();

How to edit a property on 'window', 'document'(width,height) from QtWebKit?

I tried to change like that(worked on the 'navigator' object)
page->mainFrame()->evaluateJavaScript(
"var navigator=new Object;"
"navigator.someProperty=...");
In that case, I would use the signal javaScriptWindowObjectCleared
That kicks in just before load, when the window has been cleared.
You probably want to validate the origin before doing anything, though.
That being said - and I am not too sure what you want to achieve - I wouldn't manipulate the javascript scope like that. Maintaining and deploying javascript is easier than doing the same for C++. So, I would instead just expose a simple C++ object to the javascript scope (via addToJavaScriptWindowObject), and then have the javascript code test this object and do what it has to do.
Either way, hope this helps.

Resources