AnsweredAssumed Answered

confused on adding graphic

Question asked by geonetadmin on Aug 1, 2012
Latest reply on Nov 13, 2012 by geonetadmin
Original User: keith.hurley

I'm trying to add a graphic....code as follows:

 dojo.require("esri.map");
    var map;

    function init() {
        var basemap = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer");
        if (basemap.loaded) {
            createMapAddLayers(basemap);
        }
        else {
            dojo.connect(basemap, "onLoad", createMapAddLayers(basemap));
        }
    }


    function createMapAddLayers(myService1) {
        var initExtent = new esri.geometry.Extent({ "xmin": -11044717.36, "ymin": 5133926.38, "xmax": -11042644.01, "ymax": 5135359.57, "spatialReference": { "wkid": 102100} });
        var map = new esri.Map("mapDiv", { extent: initExtent });
        map.addLayer(myService1);

        var pt = new esri.geometry.Point({ "x": -11043878.94354, "y": 5134631.03171, "spatialReference": { "wkid": 102100} });
        var sym = new esri.symbol.SimpleMarkerSymbol().setSize(10).setColor(new dojo.Color([255, 0, 0]));
        var att = { "PondNumber": "123", "RunitID": "abc", "Title": "test" };
        var infoTem = new esri.InfoTemplate("<p>RunitID: ${RunitID}</p>");
        var graphic = new esri.Graphic(pt, sym, "", infoTem);
        map.graphics.add(graphic);
    }


    dojo.addOnLoad(init);


I keep getting the error
Microsoft JScript runtime error: Unable to get value of the property 'add': object is null or undefined
on the graphics of the map.graphics.add(graphic) call.

I'm sure it's something both obvious and simple, but I'd appreciate some help as I'm a javascript moron.

Attachments

Outcomes