Arcgis Api For Javascript Qa
Arcgis Api For Javascript Qa
Click
on
the
item
to
be
directed
to
description
page.
Description
page
showing
highlighted
URL
that
can
be
copy
and
pasted
to
app
source
code.
Paste
URL
as
a
variable
layer/new
feature
layer
within
ArcGIS
Web
API
source
code.
//ArcGIS
Online
feature
service
showing
Homeless
service
agency
types
var
layer
=
new
FeatureLayer("http://services2.arcgis.com/4XlTp6SwwtAtXgjj/arcgis/rest/services/HSA_
TEST2/FeatureServer/1",
{
outFields:
["*"]
});
map.addLayer(layer);
//The
ID
for
the
map
from
ArcGIS.com
webmap
=
"e88fc77e54a844739a7a1c5affdc6c87";
//Enter
a
title,
if
no
title
is
specified,
the
webmap's
title
is
used.
title
=
"Retail
Spending
Potential";
//Enter
a
subtitle,
if
not
specified
the
ArcGIS.com
web
map's
summary
is
used
subtitle
="Downtown
Seattle
and
vicinity";
b. Instance:
an
instance
is
a
realization
of
any
object
when
using
object
oriented
programming.
An
instance
can
occur
anytime
a
program
is
run.
Instancing
a
class
means
creating
an
object
by
referencing
or
returning
to
that
class.
c. Element:
an
element
is
used
to
define
the
syntax
and
can
represent
both
functions
and
data.
For
example
an
element
used
in
ArcGIS
for
API
JavaScript
is
a
variable
(<var>),
which
can
be
used
to
document
programing
tasks,
concepts,
and
reference
information.
d. Map
Events
i. Load:
the
first
layer
has
been
added
to
the
map
ii. Layers-add-result:
all
layers
in
a
call
to
Map.addLayers()
have
been
added
iii. Extent-change:
the
center
x,y
or
level
of
detail
of
the
map
has
changed
iv. Pan:
the
map
is
being
panned
v. Resize:
the
map
containers
width
or
height
has
changed
e. Object:
Object
refers
to
an
instance
of
a
class
that
represents
variables,
functions,
and
data
structures.
It
is
typically
one
item
that
is
self
contained
and
consists
of
data
and
procedures
such
as
shapes
and
pictures
(basemap,
or
map
features).
5. What
are
the
following
files
and
their
relationships?
f.
HyperText
Markup
Language
(*.html):
HTML
is
a
mark-up
language
that
creates
a
basic
structure
and
wireframe
composed
of
elements
and
attributes.
HTML
defines
how
content
such
as
headings,
tables,
and
lists
are
viewed
in
a
web
browser.
Sample
code:
<div
id
=
"footer></div>
g. JavaScript
(*.js):
JavaScript
is
a
scripting
language
that
adds
behavior
to
a
page
such
as
animation,
interactivity,
and
functionality.
Js
targets
HTML
elements
to
interact
with
and
is
then
interpreted
by
the
web
browser.
Sample
code:
<script
type="text/javascript">
var
x
=
5;
var
y
=
6;
var
result
=
x
+
y;
</script>
h. Cascading
Style
Sheets
(*.css):
CSS
allows
you
control
over
the
formatting
and
layout
of
your
document.
It
interacts
with
the
elements
in
HTML
and
can
change
the
style,
color,
size,
and
position
of
the
elements.
It
is
recommended
to
create
a
separate
(external)
CSS
document
that
can
be
referenced
in
the
HTML
index
page.
Sample
code:
{
p
line-height:
3;
color:
red;
}
Sample
external
style
sheet
reference:
<head>
<link
rel="stylesheet"
type="text/css"
href="mystyle.css"
>
</head>
k. Where
to
find
the
built-in
widgets?
If
the
map
was
created
using
web
app
builder
then
off-panel
and
in-panel
widgets
have
been
added
to
the
map
with
a
selected
theme.
Many
of
the
widgets
have
parameters
that
allow
for
configuration
and
customization.
l. Where
to
find
widgets
developed
by
others?
:
Widgets
developed
by
others
can
be
found
in
the
API
Library
(https://developers.arcgis.com/javascript/jssamples/).
m. What
are
the
commonly
used
widgets?
I.
Attribute
tableDisplays
a
tabular
view
of
operational
layers'
attributes.
Currently,
layers
from
map
service,
feature
service
and
feature
collection
in
the
map
are
supported.
II.
CoordinateDisplays
coordinates
in
the
current
map
projection
when
moving
the
cursor
on
the
map
or
in
other
coordinate
systems
by
clicking
the
map.
III.
GeocoderEnables
finding
a
location
on
the
map.
IV.
Home
ButtonClick
to
zoom
to
map's
initial
extent.
V.
My
LocationDetects
your
physical
location
and
zooms
the
map
to
it.
VI.
Overview
MapShows
the
current
spatial
extent
of
the
map
display
as
a
grey
rectangle
relative
to
the
entire
spatial
extent
of
the
basemap
service.
VII.
ScalebarDisplays
a
scalebar
on
the
map.
VIII.
Splash--Displays
content
on
the
splash
screen.
IX.
Swipe--Shows
a
portion
of
a
layer
or
layers
on
top
of
a
map.
X.
Time
Slider--Visualizes
content
within
a
map
that
contains
time-aware
layers.
n. How
to
build
my
own
widget?
:
https://developers.arcgis.com/web-appbuilder/
o. How
to
use
a
widget?
Sample
code:
Item
selector
that
allows
the
user
to
search
items
of
specified
types.
require(['jimu/dijit/ItemSelector'],function(ItemSelector){
var
itemSelector
=
new
ItemSelector({
portalUrl:
"http://orgname.maps.arcgis.com",
itemTypes:
['Feature
Service','Map
Service']
},
srcNodeRef);...
});
Custom
Search
Optimization
widget
showing
Services
near
Washington
Park
and
OTR
7. How
to
use
API
libraries?
p. What
are
API
libraries?
:
A
set
of
pre-written
APIs
q. Where
to
find
API
libraries?
Recommended
APIs
for
web
apps
can
be
found
in
the
ArcGIS
API
for
JavaScript
hosted
by
ESRI.
r. How
to
reference
API
libraries?
Many
developers
and
consumers
of
the
API
will
use
CDN
to
reference
the
library
but
it
can
also
be
downloaded,
or
used
in
a
web
optimizer
and
compact
build
(https://developers.arcgis.com/javascript/jshelp/intro_accessapi.html)
Sample
code:
<link
rel="stylesheet"
href="http://js.arcgis.com/3.14/esri/css/esri.css">
<script
src="http://js.arcgis.com/3.14/"></script>
s. How
to
use
API
libraries?
The
default
strings
of
the
API
libraries
can
usually
be
overridden
so
that
the
developer
is
able
to
create
a
new
modified
widget
with
the
strings
specified.
Sample
code:
Simple
Renderer
API
where
the
size,
color
and
feature
can
all
be
edited.
//
AMD
require([
"esri/symbols/SimpleMarkerSymbol",
"esri/renderers/SimpleRenderer",
"dojo/_base/Color",
...
],
function(SimpleMarkerSymbol,
SimpleRenderer,
Color,
...)
{
var
symbol
=
new
SimpleMarkerSymbol();
symbol.style
=
SimpleMarkerSymbol.STYLE_SQUARE;
symbol.setSize(8);
symbol.setColor(new
Color([255,255,0,0.5]));
var
renderer
=
new
SimpleRenderer(symbol);
});
//
legacy
var
symbol
=
new
esri.symbol.SimpleMarkerSymbol();
symbol.style
=
esri.symbol.SimpleMarkerSymbol.STYLE_SQUARE;
symbol.setSize(8);
symbol.setColor(new
dojo.Color([255,255,0,0.5]));
var
renderer
=
new
esri.renderer.SimpleRenderer(symbol);
8. What
is
the
asynchronous
module
definition
(AMD)
syntax?
:
API
that
specifies
mechanism
for
defining
modules
so
that
the
model
and
its
dependencies
can
be
asynchronously
loaded.
AMD
references
local
variables
and
is
usually
exposed
through
the
require()
and
define()
functions.
AMD-compliant
modules
allow
for
flexibility
in
how
modules
are
named
once
they're
loaded.
Since
AMD
does
not
use
global
identifiers,
it
is
up
to
developers
to
name
modules
appropriately
in
their
code.
require(["dojo/dom",
"dojo/domReady!"],
function(dom){
dom.byId("helloworld").innerHTML
=
"Hello!";
});
10. How
to
use
an
ArcGIS
Online
service?
v. What
are
the
ready-to-use
services?
i.
Geosearch
and
Geocoding
(World
Geocoding
Service)
ii.
Routing
(Network
Analysis
Service)
iii.
Demographics
and
Lifestyle
maps
iv.
Live
Traffic
Map
v.
Imagery
(Landsat,
MODIS<
NAIP)
vi.
Elevation
Layers
vii.
Live
Feeds
(winds,
weather
conditions,
active
hurricanes,
and
wildfires,)
w. How
to
use
a
service?
:
Within
ArcGIS
Online,
you
use
ArcGIS
Server
web
services
as
layers
for
maps
or
you
can
add
them
as
items
to
be
shared
with
members
of
your
organization
or
the
public.
11.
What
is
an
ArcGIS
API
for
JavaScript
Web
Optimizer:
jso.arcgis.com
x. What
is
it?
:
A
web
application
that
creates
custom
builds
of
the
ArcGIS
API
for
JavaScript.
It
offers
alternatives
to
the
one
size
fits
all
build
via
the
CDN.
y. Who
needs
it?
:
This
is
more
beneficial
for
the
development
of
smaller
web
applications
because
it
can
reduce
the
number
of
http
requests
during
a
load
time.
Must
have
an
ArcGIS
Online
organization
or
ArcGIS
for
Developers
account
and
JS
API
version
3.4
or
later.
z.
Figure
shows
the
process
of
selecting
modules
creating
a
build
and
viewing
the
zipped
folder
files
(http://js.arcgis.com/o/rybackma53/MeganTestBuild/dojo/dojo.js).
14. How
to
set
up
map
and
layer
spatial
references?
a. What
the
rules
for
spatial
references?
:
In
the
API,
a
spatial
reference
class
represents
a
coordinate
system.
It
contains
a
coordinate
system
and
helper
methods
to
access
and
use
it.
The
spatial
reference
class
is
associated
with
several
other
API
classes
that
need
a
coordinate
system
to
function.
b. How
to
call
a
spatial
coordinate
system?
:
To
define
a
spatial
reference
you
will
use
the
well-know
ID
(WKID)
or
a
full
text
definition
that
supports
Geographic
Coordinate
Systems
and
Projected
Coordinate
Systems.
c. When
and
how
to
change
the
spatial
reference
of
a
map
or
a
layer?
:
To
use
a
projection
other
than
the
service
default,
define
esri.Maps
spatial
reference
by
specifying
the
constructor
option.
When
layers
and
maps
are
combined
with
different
spatial
references
then
there
can
become
disparities
in
the
viewing
and
analysis
of
the
data.
Spatial
references
can
be
referred
to
by
a
well-know
ID
(WKID).
15. How
to
set
up
the
display
of
a
web
map?
a. Extent:
if
you
include
no
extent
information
then
the
applications
default
extent
will
be
the
initial
extent
of
the
map.
b. Center:
center
point
of
the
map
using
latitude
and
longitudinal
points
on
initial
extent
of
map.
c. Size:
of
varying
graphics
of
the
initial
extent
of
map.
d. Zoom:
the
zoom
level
of
the
initial
extent
of
map.
Sample code:
var
map;
require([
"esri/map",
"esri/styles/size",
"dojo/domReady!"],
function(Map,
esriStylesSize)
{
map
=
new
Map("map",
{
basemap:
"topo",
center:
[-122.45,
37.75],
//
longitude,
latitude
zoom:
13
});
"esri/arcgis/utils",
"esri/dijit/Print",
"esri/tasks/PrintTemplate",
"esri/config",
"dojo/_base/array",
"dojo/dom",
"dojo/parser",
"dijit/layout/BorderContainer",
"dijit/layout/ContentPane",
"dojo/domReady!"
],
function(
arcgisUtils,
Print,
PrintTemplate,
esriConfig,
arrayUtils,
dom,
parser
)
{
parser.parse();
app.webmapId
=
"8315cf7d20f0484e869c4791f70f4f15";
app.printUrl
=
"http://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/PrintingToo
ls/GPServer/Export%20Web%20Map%20Task";
esriConfig.defaults.io.proxyUrl
=
"/proxy/";
var
webmap
=
arcgisUtils.createMap(app.webmapId,
"map",
{
mapOptions:
{
center:
[-85.673,
38.21],
zoom:
10
}
});
webmap.then(function(resp)
{
app.mapInfo
=
resp.itemInfo.item;
app.map
=
resp.map;
createPrintDijit(app.mapInfo.title);
});
function
createPrintDijit(printTitle)
{
var
layoutTemplate,
templateNames,
mapOnlyIndex,
templates;
//
create
an
array
of
objects
that
will
be
used
to
create
print
templates
var
layouts
=
[{
name:
"Letter
ANSI
A
Landscape",
label:
"Landscape
(PDF)",
format:
"pdf",
options:
{
legendLayers:
[],
//
empty
array
means
no
legend
scalebarUnit:
"Miles",
titleText:
printTitle
+
",
Landscape
PDF"
}
},
{
name:
"Letter
ANSI
A
Portrait",
label:
"Portrait
(Image)",
format:
"jpg",
options:
{
legendLayers:
[],
scalebarUnit:
"Miles",
18. How
to
query
a
layer?
:
When
setting
up
a
query
task
a
user
will
provide
input
to
the
query
which
could
include
selecting
features
on
a
map,
selecting
a
value
from
a
list,
or
entering
a
value
to
search
(https://developers.arcgis.com/javascript/jshelp/intro_querytask.html).
Sample
code:
function
executeQueryTask(population)
{
//set
query
based
on
what
user
typed
in
for
population;
query.where
=
"POP04
>
"
+
population;
//execute
query
queryTask.execute(query,showResults);
}
19. How
to
edit
a
layer?
:
Web
based
editing
allows
for
a
larger
group
to
add
to
and
improve
your
data.
APIs
include
widgets
that
help
you
add
editing
capabilities
to
your
application
(https://developers.arcgis.com/javascript/jshelp/inside_editing.html).
Sample
code:
require([
"esri/map",
"esri/dijit/editing/AttachmentEditor",
"dojo/dom",
...
],
function(Map,
AttachmentEditor,
dom,
...
)
{
var
map
=
new
Map(
...
);
map.infoWindow.setContent("<div
id='content'
style='width:100%'></div>");
map.infoWindow.resize(350,275);
var
attachmentEditor
=
new
AttachmentEditor({},
dom.byId("content"));
attachmentEditor.startup();
...
});
20. How
to
display
a
layer?
SimpleRenderer-
a
render
that
uses
one
symbol
only
UniqueValueRenderer-
renderer
symbolizes
groups
of
graphics
that
have
matching
attributes
ClassBreaksRenderer-
renderer
that
symbolizes
each
graphic
based
on
the
value
of
some
numeric
attribute
DotDensityRender-
provides
the
ability
to
create
dot
density
visualizations
on
data
HeatMapRender-
renders
point
data
into
a
raster
visualization
that
emphasizes
areas
of
higher
density
or
weighted
values
TemporalRenderer-
provide
time-based
rendering
of
features
in
a
feature
layer
ScaleDependentRenderer-
provides
the
capability
to
apply
multiple
scale-dependent
renderers
to
a
layer
Feature
layer
renderer
visualization
properties
setColorInfo()-renders
quantitative
data
with
color
ramp
setRotationInfo()
setSizeInfo()
setOpacityInfo
21. How
to
create
a
Popup?
You
can
create
popup
windows
by
building
info
widows
using
the
API.
Pop
up
windows
can
include
formatted
text,
images,
and
charts
(https://developers.arcgis.com/javascript/jsapi/popup-amd.html).
Sample
Code:
var
template
=
new
PopupTemplate({
title:
"Boston
Marathon
2013",
description:
"{STATE_NAME}:
{Percent_Fi}
of
starters
finished",
fieldInfos:
[{
//define
field
infos
so
we
can
specify
an
alias
fieldName:
"Number_Ent",
label:
"Entrants"
},{
fieldName:
"Number_Sta",
label:
"Starters"
},{
fieldName:
"Number_Fin",
label:
"Finishers"
}],
mediaInfos:[{
//define
the
bar
chart
caption:
"",
type:"barchart",
value:{
theme:
"Dollar",
fields:["Number_Ent","Number_Sta","Number_Fin"]
}
}]
});
22. How
to
change
the
display
order
of
multiple
layers?
Use
urls=
to
include
more
than
one
layer.
Separate
layers
with
a
comma.
The
map
dispaly
is
based
on
the
last
layer
in
the
list
or
the
slowest
one
to
load.
To
define
the
operational
layers
that
overlay
the
basemap,
use
webmap=,
layers=,
url=,
or
urls=.
If
the
layer
is
an
item
in
the
website,
use
layers=
so
you
get
all
the
layer
configurations.
If
the
layer
isn't
in
the
website,
use
url=
or
urls=.
The
layers=
parameter
accepts
a
single
item
ID
or
multiple
item
IDs.
For
multiple
layers,
use
a
comma-separated
list
of
IDs
(&layers=<itemID>,<itemID>,<itemID>).
For
example:
http://www.arcgis.com/home/webmap/viewer.html?layers=a79a3e4dc55343b08543b1b6133bfb90
,a068913914cd4fecb302b9207a532d1a
23. Please
include
all
the
questions
we
want
to
answer
for
the
homeless
project.