I have a simple GeoRSS parser that reads an feed with both polygons and points. The points draw fine, however, the polygons do not draw. It appears they are being created (according to DOM inspector), but, do not show up. Any ideas?
<script type="text/javascript">
dojo.require("esri.map");
var map;
var name = "";
var description = "";
var lat;
var lon;
var latlon = "";
var defaultSymbol;
var sym;
function init(){
var initExtent = new esri.geometry.Extent({"xmin":-16638238,"ymin":3190518,"xmax":-8811087,"ymax":9060882,"spatialReference":{"wkid":102100}});
map = new esri.Map("map",{extent:initExtent});
dojo.connect(map,"onLoad",retrieveGeoRSS);
var basemap = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer");
map.addLayer(basemap);
defaultSymbol = new esri.symbol.SimpleMarkerSymbol().setColor(new dojo.Color([255,150,0]));
sym = new esri.symbol.SimpleFillSymbol({"color":[255,255,0,64],"outline":{"color":[255,0,0,255],"width":1.5,"type":"esriSLS","style":"esriSLSDashDot"},"type":"esriSFS","style":"esriSFSSolid"});
}
function retrieveGeoRSS(){
$(document).ready(function(){
$.ajax({
// url: 'https://portal.masas-x.ca/access/go?code=9xfaletolxkxj6k8r6wl6l5k3&url=https%3A%2F%2Fcommon.masas-x.ca%2Fhub%2Ffeed%3Fsecret%3Dp9tzou%26bbox%3D-154.249%252C41.642%252C-33.751%252C60.4151%26lang%3Den%26limit%3D200&_dc=1332172293795&limit=200',
url: 'Entries.xml',
cache: false,
dataType: 'xml',
error : function(xhr, stat){
console.log(xhr, stat);
},
success: function(rss){
//$('#result').html(rss);
$(rss).find("entry").each(function(){
name = "Title: " + $(this).find("[nodeName='title']").text();
description = "Description: " + $(this).find("[nodeName='content']").text();
pointLocation = $(this).find("[nodeName='georss:point']").text();
polyLocation = $(this).find("[nodeName='georss:polygon']").text();
if (pointLocation){
pointLocationArray = pointLocation.split(" ");
lat = pointLocationArray[0];
lon = pointLocationArray[1];
addGraphics(lat,lon,name);
}
if (polyLocation){
polyLocationArray = polyLocation.split(" ");
lat = polyLocationArray[0];
lon = polyLocationArray[1];
function coordinate(x, y) {
this.x = x;
this.y = y;
}
var arr = new Array();
for (var i = 0; i < polyLocationArray.length; i++) {
arr.push(new coordinate(lon,lat));
}
addPolygonGraphics(arr,name);
}
});
}
});
});
}
function addGraphics(lat,lon,name)
{
var point = new esri.geometry.Point( {"x": lon, "y": lat," spatialReference": {" wkid": 4326} });
var finalPoint = esri.geometry.geographicToWebMercator(point);
map.graphics.add(new esri.Graphic(finalPoint, defaultSymbol));
map.infoWindow.setTitle(name);
map.infoWindow.resize(200,75);
//map.infoWindow.setContent("<b>Lat/Lon:</b> " + parseFloat(lat).toFixed(3) + ", " + parseFloat(lon).toFixed(3));
}
function addPolygonGraphics(arr,name)
{
var polygon = new esri.geometry.Polygon(new esri.SpatialReference({wkid:4326}));
polygon.addRing(arr);
var poly_wm = esri.geometry.geographicToWebMercator(polygon);
var graphicPOLY = new esri.Graphic(poly_wm,sym);
map.graphics.add(graphicPOLY);
map.infoWindow.setTitle(name);
map.infoWindow.resize(200,75);
//map.infoWindow.setContent("<b>Lat/Lon:</b> " + parseFloat(lat).toFixed(3) + ", " + parseFloat(lon).toFixed(3));
}
dojo.addOnLoad(init);
</script>
Sample here: http://cosmosbeta.surrey.ca/apps/cosmosbeta/COP/test.html