Javascript API initializes web map with one undesired graphic

1708
3
02-23-2016 03:49 AM
PlinioSantos
New Contributor III

I just realized that a webmap will always be initialized with one graphic and I can't figure out the reazon for it.

Is it a bug? If not, can someone explain to me why that graphic has been added?

 

I copied below a sample code to test this observation:

(taken from Build a web map using ArcGIS.com | Guide | ArcGIS API for JavaScript)

<!DOCTYPE html> <html> <head> <title>Create a Web Map</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge">  <link rel="stylesheet" type="text/css" href="https://js.arcgis.com/3.15/esri/css/esri.css"> <style>   html,body,#mapDiv,.map.container{     padding:0;     margin:0;     height:100%;   } </style>  <script>var dojoConfig = { parseOnLoad:true };</script> <script src="https://js.arcgis.com/3.15compact/"></script> <script>   var map;   require([   "esri/map",   "esri/arcgis/utils",   "dojo/domReady!"   ], function(Map, arcgisUtils){     arcgisUtils.createMap('1a40fa5cc1ab4569b79f45444d728067', "mapDiv").then(function (response) {       map = response.map;     });   }); </script> </head>  <body>   <div id="mapDiv"></div> </body> </html>

 

Then, just open a web developer tool and inspects the objec map.graphics.graphics:

map.graphics.graphics [Object] map.graphics.graphics.length 1 map.graphics.graphics[0].geometry Object {type: "point", x: 0, y: 0, spatialReference: Object}
0 Kudos
3 Replies
TyroneBiggums
Occasional Contributor III

I have noticed this too. You definitely have to keep that in mind if you're maintaining a graphics collection based on length/count. I wonder why they do it too. I've asked before, and received no answer.

0 Kudos
PlinioSantos
New Contributor III

Tyrone Biggums​ Also worth mentioning that I didn't noticed any map misbehavior after remove that 'strange' graphic. Let's hope we get an answer this time

0 Kudos
TyroneBiggums
Occasional Contributor III

Yea, I played with that graphic a little bit too. My guess is that it's added to kick start the graphicLayerIds collection. Or maybe they found a bug that was resolved by adding the graphic? I hope to hear about it, too.

0 Kudos