ArcGIS API for JavaScript 4 equivalent to JavaScript 3 next and previous extent? - arcgis-js-api

I'm trying to find the JavaScript 4 equivalent to the next extent and previous extent methods discussed in the JavaScript 3 documentation. This link takes you to the page I'm referring to in the documentation for 3. There is no path similar to esri/toolbars/navigation in the documentation for 4 and I can't seem to find it anywhere else.
https://developers.arcgis.com/javascript/3/jsapi/navigation-amd.html
Much appreciative!

There is no out-of-the-box equivalent for the 3x Navigation toolbar in 4x, nor its specific zoomToNextExtent/zoomToPrevExtent methods. See https://developers.arcgis.com/javascript/latest/functionality-matrix/#esritoolbars
To replicate those methods you would have to watch for extent changes and keep track of them yourselves:
let extentArray = [];
// Get the new extent of the view only when view is stationary.
watchUtils.whenTrue(view, "stationary", function() {
if (view.extent) {
extentArray.push(view.extent.clone());
}
});

Related

Table Of Contents(Side Bar) for Cocoa App's Help Book

I'm in the process of building a help book for my application, mainly using apple's documentation here, however it appears to be a little dated. In Yosemite OS X 10.10, apple's own apps have a collapsable side bar that displays the table of contents for the help bundle
Although, the side bar button is present on my own app I have no idea how to access it. Does anyone know how to access this sidebar? and provide content for our own apps?
I've just come up against the same problem, and I had to dig around in Apple Mail's help files to find out what they were using. Basically they have constructed their sidebar in HTML/CSS, and its not a part of the help viewer.
To enable the "Table of Contents" button in the help viewer, you need to use the javascript function:
window.HelpViewer.showTOCButton(bool, function, function);
For a more explicit example, the following code snippet will enable the "Table of Contents" button in Apple's help viewer, and link it to the function "toggleNavigation".
if ("HelpViewer" in window && "showTOCButton" in window.HelpViewer) {
window.setTimeout(function () {
window.HelpViewer.showTOCButton(true, toggleNavigation, toggleNavigation);
window.HelpViewer.setTOCButton(true);
}, 100);
}
The toggleNavigation function will contain code to open your sidebar.
function toggleNavigation() {
// YOUR CODE HERE
}
I found that using window.onload doesn't seem to work, but setting a timeout for 100ms did. In Mail, Apple used their equivalent of the "toggleNavigation" function, for both of the function parameters, as per the example. The third parameter is called when you press the "Table of Contents" button, but I've not worked out what the second one is for.

Add JavaScript documentation Sencha Architect

Is it possible to add documentation (not just comments) to your javascript methods in Sencha Architect. I cannot seem to add lines above methods because of the specific method views in Architect.
I am talking about the following documentation:
/**
* this documentation
*/
bla: function() {
//I do know how to add this comment!
}
UPDATE:
Seems that it is not possible :(
http://www.sencha.com/forum/showthread.php?281079-Sencha-Architect-Code-Documentation-%28JSDocs%
I will keep this thread open to see if someone knows a workaround to the problem.
Architect 3.1 or 3.1.1 will add commenting. It's done in prototype form but we are racing to add Ext JS 5 so it's on the back burner until then.

SoundCloud Widget API setVolume Method broken?

I'm successfully using Soundcloud's widget API, except the setVolume() method is broken :(
First, I love the widget, but I'm blown away that after all that amazing work there is no volume control available! People will immediately "back button" out of my site when they hear 100% audio and I can't alter it using setVolume()... I have to get it working or pull it :(
Here is what is happening, I have an instance named "widget" (which loads and plays well on the page).
widget.bind(SC.Widget.Events.READY, function() {
$('#audioIndictments').removeClass('remove'); // This disables a CSS rule, making the soundCloud iframe visible
widget.setVolume(10); // This should set the volume to 10% but doesn't :(
widget.getVolume(function(vol){
console.log(vol); // This outputs 0.1 in the console :/
console.log(widget); // This outputs the object in the console and I don't see anything out of whack :|
});
widget.play(); // This successfully fires up the widget and the audio begins playing :)
widget.setVolume(10); // Just to see if it makes a difference, after the play() method, I ran setVolume again after the play() method and still no change :(
widget.getVolume(function(vol){
console.log(vol); // This still outputs 0.1 in the console :/
});
});
Strange results. I found another blogger who asked a similar question and got no satisfactory answer. What's the deal here? What am I not seeing?
Thank you for taking the time :)
Try using the a volume between 0 and 1. This fixed it for me.
0.25 = 25% volume
I too am facing the same issue and I discovered that the volume does not reset to full when setVolume method is called outside of the READY event. This is why the setVolume button on the SC api playground works since it's called externally. But there is another problem - when the next track in the playlist is loaded into the widget, it resets the volume back to full and as a result, deafens the user.
I've used a hacky workaround until this is fixed.
Setup a new PLAY_PROGRESS event and call the method inside there.
widget.bind(SC.Widget.Events.PLAY_PROGRESS, function() {
widget.setVolume(10);
});
The setVolume method will continuously be called when the track is played. Not ideal but it works.
If you have a slider in place for volume then you may use this instead:
widget.bind(SC.Widget.Events.PLAY_PROGRESS, function() {
var vol = jQuery('.slider').val();
widget.setVolume(vol);
});

Accessing javascript library in iframe in greasemonkey script

I'm trying to access Dojo within my webapp, and having issues getting what I need. Specifically, I have a webapp in an iframe with different versions of Dojo loaded:
In Firebug, I can do this:
window.dojo.version; // 1.7
window.frames[0].window.dojo.version; // 1.0
(Note iframe is in same domain as parent)
In GreaseMonkey, I can't find either version of Dojo:
dojo // undefined
window.dojo // undefined
window.frames[0].window.dojo // undefined
I started looking into unsafeWindow which supposedly I shouldn't use. It gives me access to the window'd Dojo, but not the iframe'd dojo I actually want.
unsafeWindow.dojo.version // 1.7 (wrong version)
unsafeWindow.frames[0].dojo // undefined
unsafeWindow.frames[0].window.dojo // undefined
window.frames[0].window.dojo // undefined
window.frames[0].unsafeWindow // undefined
window.frames[0].window.unsafeWindow // undefined
I've tried withDoc but I suspect I'm using it incorrectly:
unsafeWindow.dojo.withDoc(window.frames[0].window, function(){
var dijit = unsafeWindow.dijit; // seems wrong; doesn't work
var widget = dijit.byId('someWidgetInsideIframe');
console.log(widget); // undefined
}, this);
Any suggestions on other things I can try to get access to Dojo 1.0 in the iframe? Or if not that, at least figure out how to get access to dojo widgets defined in the iframe using the Dojo I do have access to?
I would expect unsafeWindow.frames[0].window.dojo.version; to work when GM is running on the main page (see below). The fact that it doesn't is a bug in my opinion, but the lead GM dev might not agree. Consider filing a bug report.
However, Greasemonkey normally processes frames/iframes as though they were standalone pages (with some exceptions). This means that the script will fire once for the main page and once for each frame whose src matches the #include/#exclude/#match directives. This also means that things like window.frames[0] will not be defined in every pass.
You can tell you are in the right frame with code like this:
if (window.self == window.top.frames[0]) {
//-- Currently running in the target frame
unsafeWindow.console.log ("dojo.version:", unsafeWindow.dojo.version);
}
else
unsafeWindow.console.log ("These are not droids... Or, er something.");

Removing Directions markers from the Google Maps API V3

To remove a normal marker from a map, I understand you simply call marker.setMap(null), but when implementing the Google Maps directions services, it automatically adds markers A and B onto the map ( calculating directions from point A to point B ). I do not have control over these markers, so I cannot remove them in the normal way. So how can I remove these markers (I have custom markers on the map instead)?
Set the suppressMarkers option to true when creating your DirectionsRenderer object and then the markers won't show up. You could also change the style or icon of the markers. See the API spec for DirectionsRendererOptions for other properties you can set.
...
directionsDisplay = new google.maps.DirectionsRenderer({suppressMarkers: true});
...
EDIT: It looks like the API changed a little bit since my original answer almost 6 years ago, so the answer from #joni-jones is now the correct way. I tweaked my example above to reflect that.
I had a similar problem. The previous solution did not help me. But I tried this:
var directionsDisplay = new google.maps.DirectionsRenderer({suppressMarkers: true}); And it's work.