correaj

Accessing Map Methods after using .utils.createMap

Discussion created by correaj on Jul 26, 2012
Latest reply on Jul 26, 2012 by stevel
Hi anyone and everyone!

I've created a simple map on arcgis.com and am able to render the map in my web pages using a map key. However, I'd like to be able to add a point from my server side code. Here is my code so far. How do add a new graphic point? ESRI has terribly limited documentation and usually its examples cut out a lot of dependencies.

dojo.require("esri.map");
    dojo.require("esri.arcgis.utils");
    dojo.require("esri.layers.agstiled");
    esri.config.defaults.geometryService = new esri.tasks.GeometryService('http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer');
     

    var mapDeferred;

    function init() {

        var mapid = "61b91bd7159d4712ac50988e5fd7d4c7"
        mapDeferred = esri.arcgis.utils.createMap(mapid, "map", {
            mapOptions: {
                slider: true,
                nav: false
            }

        });

    }

    dojo.ready(init);

    function addPointToMap(lon, lat) {

        var point = new esri.geometry.Point(lon, lat, mapDeferred.spatialReference);
        var symbol = new esri.symbol.SimpleMarkerSymbol().setColor(new dojo.Color([0, 255, 0]));
        var graphic = new esri.Graphic(point, symbol);


        mapDeferred.graphics.add(graphic);

    }
   
    dojo.ready(addPointToMap);

below are my error messages

[ATTACH=CONFIG]16428[/ATTACH]

Attachments

Outcomes