Problems with TOC or map

2655
9
10-14-2013 03:50 AM
DominikSchlarmann
Occasional Contributor
Hello,
I have a wired problem in my map.
1.) Either I can use NLiu's TOC, but the map doesn't update when I zoom. I have to pan the to update the map. Also I can see the lines for the editor and measurement widget. These are working, but I don't see any lines.
2.) Or I can have a map, where the map updates on zooming without panning. There I can also see the line features of measurement and editor tool. But I can't use nliu's TOC. The TOC doesn't display and all layers are added.

I assume that this error is caused by a wrong placement of
map.on("layers-add-result", initEditor);
because this is more or less the difference between both versions.

Here are the jsfiddles:
No refresh of map with working TOC, but no lines of editor and measurement tool (1):
http://jsfiddle.net/3zpMT/

Refresh of TOC with working measurement and editor tool, but no toc (2):
http://jsfiddle.net/DfnnD/



Would be awesome, if anybody could help me.
Thanks in advance,
Dominik
0 Kudos
9 Replies
by Anonymous User
Not applicable
Original User: jeff.pace

The TOC has its own add-layers listener

      dojo.connect(this.map, 'onLayerAdd', this, function(layer) {
        this.layerInfos.push({
          layer: layer
        });
        this.refresh();
      });


Therefore when you add your listener and then do add-layers its being fired twice.

I commented out the addlayer listeners in the TOC, and added the call to the toc to  my main listener
0 Kudos
DominikSchlarmann
Occasional Contributor
Dear Jeff (and of course everybody else:),
I've tried to modify my code as suggested but unfortunately no success. The map doesn't update so I have to pan again to focus the map. Surely I've missplaced the function, deleted a wrong line or commeted out the wrong part.
Would it be possible that you provide your modification in my code in a jsfiddle?

Thanks you very much.
0 Kudos
by Anonymous User
Not applicable
Original User: jeff.pace

i trieed your sample with the working TOC.

THe edit lines are not drawing because it cannot find your proxy

http://fiddle.jshell.net/proxy/?http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Hydrograp...

is what it is trying to hit.
0 Kudos
DominikSchlarmann
Occasional Contributor
Maybe it's becuase the example Esri feature Service doesn't allow to store created edits. I think, it's just for demo.
I've used this editing service: https://developers.arcgis.com/en/javascript/jssamples/ed_simpletoolbar.html
...I have modified version with own services, which should be used later on. I've just created this version with esri services for the forum.

So...is there a way to have a working toc, to see lines of measurement tool and editing tool and to have an updating map, where I don't have to pan for an update?
Thank you very much for your support 🙂
0 Kudos
by Anonymous User
Not applicable
Original User: jeff.pace

this line isnt right

esriConfig.defaults.io.proxyUrl = "/proxy";

it should be proxy.jsp, or proxy.php, etc.. and needs to point to a valid proxy file, which you don't have set up
0 Kudos
DominikSchlarmann
Occasional Contributor
Okay....I will try to solve this problem will report in a couple of minutes (hopefully ;)).

Cheers,
Dominik
0 Kudos
by Anonymous User
Not applicable
Original User: Schlomm

Okay...following the guideline here, I've set up a proxy.jsp file.
Just for clarification:
I've downloaded the proxy.jsp template, extracted it in the root of my webserver (in my case it's ISS 😎 and modified just the following lines:
String[] serverUrls = {
  //"<url>[,<token>]"
  //For ex. (secured server): "http://myserver.mycompany.com/arcgis/rest/services,ayn2C2iPvqjeqWoXwV6rjmr43kyo23mhIPnXz2CEiMA6rVu0xR0St8gKsd0olv8a"
  //For ex. (non-secured server): "http://sampleserver1.arcgisonline.com/arcgis/rest/services"
  "http://sampleserver1.arcgisonline.com/arcgis/rest/services",
  "http://sampleserver2.arcgisonline.com/arcgis/rest/services" //NOTE - no comma after the last item
};


to

String[] serverUrls = {
  //"<url>[,<token>]"
  //For ex. (secured server): "http://myserver.mycompany.com/arcgis/rest/services,ayn2C2iPvqjeqWoXwV6rjmr43kyo23mhIPnXz2CEiMA6rVu0xR0St8gKsd0olv8a"
  //For ex. (non-secured server): "http://sampleserver1.arcgisonline.com/arcgis/rest/services"
"http://geo-arcgis.abc-efg.de:6080/arcgis/rest/services"
};
[
For now I want to try it out without https.

Then I've modified the line in the html file to:
esri.config.defaults.io.proxyUrl = "proxy.jsp";

The html file and the proxy.jsp are both stored in the root folder of the ISS WebServer:
C:\inetpub\wwwroot\webmap.html
C:\inetpub\wwwroot\proxy.jsp

Everything right?
It would be so nice, to have a fully working webapplication with a working TOC, visible measurement and editor features and that the map update itself.

@Jeff: I've sent you a private message. I hope, it's okay.
0 Kudos
DominikSchlarmann
Occasional Contributor
Sorry for pushing this up :(, but it's crucial for me that the map updates on it's own and to have the working toc.
Maybe it's just the right re-positioning of the code in post #2?
Or is the configuration of the proxy elementary to have a working toc/self-updating (without panning) map?

Anyway: Thanks a lot 🙂
0 Kudos
AshleyPeters
Occasional Contributor III

Dominik,

You may have resolved this problem by now. But, I ran into the same issue earlier this week. I was just able to resolve it by following this example: Add two dynamic maps | ArcGIS API for JavaScript . Maybe it will work for you as well.

Ashley

0 Kudos