Select to view content in your preferred language

confused on adding graphic

903
3
08-01-2012 08:06 AM
by Anonymous User
Not applicable
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.
0 Kudos
3 Replies
by Anonymous User
Not applicable
Original User: keith.hurley

Please disregard....problem solved.
0 Kudos
StephenLead
Honored Contributor
Please disregard....problem solved.


Can you post the resolution? This will help in the future if someone searches on the error message, and this forum post comes up.
0 Kudos
by Anonymous User
Not applicable
Original User: pragnesh.patel

[PHP][/PHP]
Please disregard....problem solved.


Please can you post which solution you used? as i am getting same error.
0 Kudos