POST
|
Thank you Robert and Arne. I provide the original example with applied workarounds from you both and some additions. To get it to work in all use cases with v4.8+, I had to do the following (please note the two "workaround"-comments): require([
"esri/views/MapView",
"esri/Map",
"esri/layers/MapImageLayer",
"esri/core/watchUtils"
], function(
MapView, Map, MapImageLayer, watchUtils
) {
var mapConfigs = [
{},
{},
{}
];
/************************************************************
* Create multiple map instances, each with one
* MapImageLayer-instance added to it..
************************************************************/
var maps = mapConfigs.map(function(mapConfig) {
var map = new Map(mapConfig);
map.add(new MapImageLayer({
url: 'https://sampleserver6.arcgisonline.com/arcgis/rest/services/SampleWorldCities/MapServer'
}));
return map;
});
/************************************************************
* Initialize the View with the first Map
************************************************************/
var view = new MapView({
map: maps[0],
container: "viewDiv"
});
// Workaround for v4.8+
view.when(function() {
view.goTo(view.extent.clone());
});
document.querySelector(".btns").addEventListener("click", function(
event) {
/************************************************************
* On a button click, change the map of the View
************************************************************/
var id = event.target.getAttribute("data-id");
if (id) {
var map = maps[id];
view.map = map;
// Workaround for v4.8+
watchUtils.whenTrue(view, "ready", function() {
watchUtils.whenTrueOnce(view, "stationary", function() {
view.goTo(view.extent.clone());
});
});
var nodes = document.querySelectorAll(".btn-switch");
for (var idx = 0; idx < nodes.length; idx++) {
var node = nodes[idx];
var mapIndex = node.getAttribute("data-id");
if (mapIndex === id) {
node.classList.add("active-map");
} else {
node.classList.remove("active-map");
}
}
}
});
}); If I go back to 4.7 - i can inactivate the two commented workaround sections and see the mapView loaded both initially and when switching between the different map-objects. Using 4.8 or later, I find that I need the first workaround section to trigger the initial data-fetching for the default map object. The second workaround section is needed for when I swap the map object. Note that it is a nested watcher, it wasn't sufficient with just 'stationary' or 'ready' - but a combination of both.. Its an acceptable workaround, even if the user experience differ somewhat (was a smoother and somewhat faster switch with 4.7). Thanks again!
... View more
11-23-2018
05:44 AM
|
0
|
1
|
954
|
POST
|
Hi, I provided two example use cases of how to update the property "map" of a MapView instance. These both worked pre-v4.8. These use cases involves a map with a single MapImageLayer. It seems to be working better with default basemap-layers, although not custom created ones (new Basemap(...)).. Also, updating the extent or using goTo() doesn't trigger map data fetching. Since I need to be able to utilize the possibility of changing the map property of a MapView, I would appreciate it if someone has any suggestions of workarounds? I imagine that this bug is already discovered and reported, otherwise I hope this question is sufficient to confirm that it is a bug. Maybe it is fixed within the same fix as https://community.esri.com/thread/223936-js-api-49-ie11-updating-the-map-property-on-a-mapview-doesnt-work , but I just wanted to be sure to cover these use cases as well. Thanks in advance, Sebastian
... View more
11-15-2018
06:32 AM
|
0
|
6
|
1501
|
POST
|
Hello, Since updating to v4.9, i have had issues in IE 11 with updating the map property of the MapView. It may work on the first update, but then the second change would error out. I have addressed a similar use case in a previous question (related to the LayerList widget at that time): [JS API 4.x] SPA with multiple map configurations . There is a sample from Esri in which one can re-pro this issue (in IE 11 that is): Swap web maps in the same view | ArcGIS API for JavaScript 4.9 Does anyone know if there is any workaround to this issue, or would I have to go back to 4.7/4.8? Regards, Sebastian
... View more
11-05-2018
05:48 AM
|
0
|
2
|
3484
|
POST
|
Thank you for your answer. Yes, I imagined the possibility of it being a bug - however I noticed we actually recreate some widgets when the map changed, which in fact seem to have triggered this error. The error mentioned above would present itself when I recreated the Print widget, rather than the LayerList widget. Anyways, the key question here was regarding the ability to reuse the MapView instance and then in turn reuse widget instances depending on the same MapView. I feel I have gotten the answer to that. Regards, Sebastian
... View more
05-17-2018
06:16 AM
|
0
|
0
|
608
|
POST
|
Hi, We are currently developing a GIS-SPA, in which the user should be able to choose between several map configurations, lets call them "map modes". These map modes will present different map layers from different sources, render different tools available etc. The user should be able to go back and forth between these map modes, keeping the state of some mapView-properties like extent, scale etc. Our initial idea was to always work with a single instance of the MapView, while having several instances of the Map-class. When the user would switch to a different map mode, we simple replace the instance of the Map with the one corresponding to the current map mode, informing out MapView of this new Map it should be viewing. We also have a single instance of LayerList, connected to our one MapView-instance. Switching "map mode" was working just fine in 4.6, the MapView loaded the new map config and the LayerList was automatically updated. After updating to 4.7, the MapView seems to be loading the new map config correctly, but the LayerList produces a DOM-exception: 'Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node. Now, after reading "A Map object should be created prior to a view so it can be passed into the map property of that view..." in the API Reference, it got me thinking that maybe we are going about this map mode handling the wrong way. Would we perhaps be better off creating a sort of bundle for the Map and MapView, keeping a one-to-one relation for these entities, for each of our map modes? Would this in turn also call for having multiple instances of the LayerList? Thanks in advance, Sebastian
... View more
05-17-2018
01:19 AM
|
0
|
2
|
728
|
POST
|
Hi, This behaviour is new in 4.3. I have a Map with an ImageryLayer, a MapImageLayer and some Graphics. When the Map is displayed in a window with a width greater then ~2000px, the MapImageLayer and the Graphics gets an offset to the ImageryLayer. This offset seems to be relative to the window width, as the offset increases if I increase the window width. In the attachments you can see an example of this behaviour. Are there any workarounds for this issue? The majority of our users will be using this app on screens with a resolution of 2560x1440 or greater. Thanks in advance, Sebastian
... View more
04-19-2017
02:15 AM
|
0
|
1
|
574
|
POST
|
Thanks for your responses. Please get back on this matter when a solution is available.
... View more
10-06-2016
11:47 PM
|
0
|
0
|
934
|
POST
|
Hi, I have some issues getting graphics on the map view with the latest version 4.1 of the JS API. Last thing I tested was to switch back to the 4.0 version, with which the graphics actually were displayed. What is different compared to the working sandbox sample: Get Started Graphics, is the fact that I apply spatial references. I have submitted an html-file with this question with sample code. Try to switch between the dependencies (4.0/4.1) at the top of the document and notice the difference of when the graphics displays and not. Can someone confirm this bug, or tell me if I am missing something? Thanks in advance, Sebastian
... View more
10-04-2016
11:55 PM
|
0
|
5
|
2033
|
Online Status |
Offline
|
Date Last Visited |
02-10-2021
09:26 AM
|