correaj

My added point is in BFE

Discussion created by correaj on Jul 26, 2012
Latest reply on Jul 27, 2012 by correaj
Well not necessarily Bum Effing Egypt but 200 km south of Ghana. This means that my points coordinates are at 0. But why?

Here is my code.

dojo.require("dijit.dijit");
    dojo.require("dijit.layout.BorderContainer");
    dojo.require("dijit.layout.ContentPane");
    dojo.require("esri.map");
    dojo.require("esri.arcgis.utils");
    dojo.require("esri.dijit.Legend");
    dojo.require("esri.dijit.Scalebar");

    esri.config.defaults.geometryService = new esri.tasks.GeometryService('http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer');
     

   
    var map;
    var x = eval('@Model.Longitude'), y = eval('@Model.Latitude');


    function init() {

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

        });

        mapDeferred.addCallback(function (response) {

            map = response.map;

            //resize the map when the browser resizes
            dojo.connect(dijit.byId('map'), 'resize', map, map.resize);
            //add the legend

            if (map.loaded) {
                addPointToMap( x, y );
            }
            else {
                dojo.connect(map, "onLoad", function () {
                    addPointToMap(x, y);
                });
            }
        });
        mapDeferred.addErrback(function (error) {
            console.log("Map creation failed: ", dojo.toJson(error));
        });

    }


    function addPointToMap(lon, lat) {
    

        var point = new esri.geometry.Point(parseFloat(lon), parseFloat(lat), new esri.SpatialReference({ wkid: 4326 }));

       
       
        var symbol = new esri.symbol.SimpleMarkerSymbol().setColor(new dojo.Color([0, 255, 0]));
        var graphic = new esri.Graphic(point, symbol);


        map.graphics.add(graphic);

    }

    dojo.ready(init);
   

</script>
<div id="map"  style="width: 650px; height: 600px; border: 1px solid #000;">
</div>

Outcomes