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}
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.
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
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.