Select to view content in your preferred language

New to scripting - Need help with a basic script with functions

1459
15
Jump to solution
02-26-2014 05:43 AM
SuzanneRoussie
Emerging Contributor
Hi,

I am in the process of putting together a basic map by learning off the tutorials and examples found on the JavaScript examples site and I am trying to use a home button, legend, and scale on the same map.  I had the home button and scale working but when I added the script for the legend it stopped working.  I was wondering if there was a limit on how many functions could be called the way I have it set up or if I am missing something else. I am sure there is a different way to do this but since I have never written anything in JavaScript before I thought this was the best way to learn. I have enclosed the text file of my code.

thanks,
Sue
0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor
You have a typo

"esri/map", "esri/layers/FeatureLayer", "esri/dijit/Legend",       "esri/digit/Scalebar","esri/dijit/HomeButton",       "dojo/_base/array", "dojo/parser",       "dijit/layout/BorderContainer", "dijit/layout/ContentPane",        "dijit/layout/AccordionContainer", "dojo/domReady!"


That should be  "esri/dijit/Scalebar"

View solution in original post

0 Kudos
15 Replies
KenBuja
MVP Esteemed Contributor
You have a typo

"esri/map", "esri/layers/FeatureLayer", "esri/dijit/Legend",       "esri/digit/Scalebar","esri/dijit/HomeButton",       "dojo/_base/array", "dojo/parser",       "dijit/layout/BorderContainer", "dijit/layout/ContentPane",        "dijit/layout/AccordionContainer", "dojo/domReady!"


That should be  "esri/dijit/Scalebar"
0 Kudos
JakeSkinner
Esri Esteemed Contributor
You are also missing a '{' in the style tag for the #map DIV.  Also, if you want the legend to display the layers, you will need to change your extent to where they are visible.  Ex:

map = new Map("map", {
        basemap:"streets",
        center: [-96.509, 38.367],
        zoom: 14
      });
MichaelVolz
Esteemed Contributor
Would this file just need to be added to a server that has IIS in the following location:

\\ServerName\c$\inetpub\wwwroot

in order to have a simple working web application?
0 Kudos
TimWitt
Deactivated User
Would this file just need to be added to a server that has IIS in the following location:

\\ServerName\c$\inetpub\wwwroot

in order to have a simple working web application?


Exactly, just like the Flex application.
0 Kudos
SuzanneRoussie
Emerging Contributor
Thanks, the typo and missing { fixed it.  I have the extent set at 7 so the state of NY appears as a whole for now and the layers are triggered when you zoom in.  I have other layers that need to go on that will be visible at that level, just wanted to get the basics working for now.  It's a slow process when you are learning.  Appreciate the help.
Sue
0 Kudos
KenBuja
MVP Esteemed Contributor
Glad to help. Please click the check mark in the post that best answered your question and the up arrows on the posts that were helpful. This will help others who may be searching about this topic.
0 Kudos
SuzanneRoussie
Emerging Contributor
All set.  Thanks again.
0 Kudos
MichaelVolz
Esteemed Contributor
Question in regards to this sample application.

I added my own mapservice layer and it gets added to the map and the legend.

Why don't the ESRI mapservices get added to the legend?  I don't see a place in the text file where they are being excluded from the legend.
0 Kudos
JakeSkinner
Esri Esteemed Contributor
The 'layerInfos' option controls this.  See the help here.

Specify a subset of the layers in the map to display in the legend. If not set all layers in the map will display in the legend.
0 Kudos