dipti_sheth

Polygon not showing up

Discussion created by dipti_sheth on Apr 21, 2014
Latest reply on Apr 23, 2014 by dipti_sheth
Hi,

Following is my code:


function LoadEsriTrees() {

var divEsriMap = $mover.find('div#mapDiv').attr('id');

require(
["esri/map", "esri/layers/GraphicsLayer", "dojo/_base/array", "esri/geometry/Point", "esri/symbols/SimpleMarkerSymbol", "dojo/_base/Color", "esri/graphic", "esri/InfoTemplate",
"esri/layers/ArcGISDynamicMapServiceLayer", "esri/layers/ImageParameters"],
function (Map, GraphicsLayer, array, Point, SimpleMarkerSymbol, Color, Graphic, InfoTemplate, ArcGISDynamicMapServiceLayer, ImageParameters) {

map = new Map(divEsriMap, {

center: [174.605, -37.119],
zoom: 15
});

//var basemap = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer", { id: 'basemap' });

var basemap = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer", { id: 'basemap' });
map.addLayer(basemap);

//show polygon
dojo.connect(map, 'onLoad', function () {
// var myPolygon = new esri.geometry.Polygon(new esri.SpatialReference({ wkid: 4326 }));

var myPolygon = new esri.geometry.Polygon([[174.605111568859, -37.119413675388707], [174.6051123299834, -37.119449718193458], [174.60515905129122, -37.119530204987136], [174.60540067619004, -37.119779304335452], [174.60554255499551, -37.120101860545844], [174.60568043759687, -37.120235191897571], [174.60572696965184, -37.1203066677341], [174.60572849253467, -37.120378753310746], [174.60570674933629, -37.120415100973361], [174.60560757225889, -37.120515590528086], [174.60554177129595, -37.120597601350227], [174.60549026791193, -37.120823630882519], [174.6054873903158, -37.121220253972716], [174.6055119446122, -37.122382633739591], [174.60513274122792, -37.119350295725816], [174.605111568859, -37.119413675388707]]);


// map is in web mercator so transform the geometry
// var poly_wm = esri.geometry.geographicToWebMercator(myPolygon);

// var symbol = new esri.symbol.SimpleFillSymbol().setStyle(esri.symbol.SimpleFillSymbol.STYLE_SOLID);

var symbol = new esri.symbol.SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID,
new SimpleLineSymbol(SimpleLineSymbol.STYLE_DASHDOT,new Color([255, 0, 0]), 2), new Color([255, 255, 0, 0.25]) );

// polygonGraphic = new esri.Graphic(poly_wm, symbol);

polygonGraphic = new esri.Graphic(myPolygon, symbol);
map.graphics.add(polygonGraphic);
});

}
);
}




Can any one please help me to locate polygon on the map? I don't know..where I'm getting wrong, its not showing up polygon on the map.

Thanks,

Dipti Sheth

Outcomes