POST
|
Aha! Found the problem - actually had nothing to do with the code (at least not directly). Someone slipped a non-printing character into one of the database entries, back in 1999 - that was causing my json parser to terminate unexpectedly, and so the map never got any data to populate... One I added a filter to take out the extraneous characters, works perfectly! Dave
... View more
07-25-2012
09:07 AM
|
0
|
0
|
1188
|
POST
|
Steve, Here's my javascript listing (it's not on the production site yet): dojo.require("dijit.layout.BorderContainer"); dojo.require("dijit.layout.ContentPane"); dojo.require("esri.map"); dojo.require("esri.dijit.Popup"); dojo.require("extras.ClusterLayer"); var map, clusterlayer; function init() { var popupOptions = { "markerSymbol": new esri.symbol.SimpleMarkerSymbol("circle", 20, null, new dojo.Color([0, 0, 0, 0.25])), "marginLeft": "20", "marginTop": "20" }; var popup = new esri.dijit.Popup(popupOptions, dojo.create("div")); map = new esri.Map("map", {infoWindow: popup}); var basemap = new esri.layers.ArcGISTiledMapServiceLayer("http://services.arcgisonline.com/ArcGIS/rest/services/Ocean_Basemap/MapServer"); map.addLayer(basemap); dojo.connect(map, 'onLoad', function(theMap) { //resize the map when the browser resizes dojo.connect(dijit.byId('map', 'resize', map,map.resize)); dojo.style(dojo.query("a.action.zoomTo")[0], "display", "none"); var markers = <%=getmarkers%>; addClusters(markers); }); } function readData(){ var m = <%=getmarkers%>; //getmarkers is a json file with location and description data } function addClusters(resp) { var markerInfo = {}; var wgs = new esri.SpatialReference({ "wkid": 4326 }); //console.log("Add marker info"); markerInfo.data = dojo.map(resp, function(p) { var latlng = new esri.geometry.Point(parseFloat(p.lat), parseFloat(p.lng), wgs); var webMercator = esri.geometry.geographicToWebMercator(latlng); var attributes = { "Victim": p.Victim, "Description": p.Description, "Date": p.Date }; return { "x": webMercator.x, "y": webMercator.y, "attributes": attributes }; }); // popupTemplate to work with attributes specific to this dataset var popupTemplate = esri.dijit.PopupTemplate({ "title": "", "fieldInfos": [ { "fieldName": "Victim", visible: true }, { "fieldName": "Description", visible: true }, { "fieldName": "Date", visible: true } ] }); // cluster layer that uses OpenLayers style clustering clusterLayer = new extras.ClusterLayer({ "data": markerInfo.data, "distance": 100, "id": "clusters", "labelColor": "#fff", "labelOffset": 10, "resolution": map.extent.getWidth() / map.width, "singleColor": "#888", "singleTemplate": popupTemplate }); var defaultSym = new esri.symbol.SimpleMarkerSymbol().setSize(4); var renderer = new esri.renderer.ClassBreaksRenderer(defaultSym, "clusterCount"); var blue = new esri.symbol.PictureMarkerSymbol("http://static.arcgis.com/images/Symbols/Shapes/BluePin1LargeB.png", 32, 32).setOffset(0, 15); var green = new esri.symbol.PictureMarkerSymbol("http://static.arcgis.com/images/Symbols/Shapes/GreenPin1LargeB.png", 64, 64).setOffset(0, 15); var red = new esri.symbol.PictureMarkerSymbol("http://static.arcgis.com/images/Symbols/Shapes/RedPin1LargeB.png", 72, 72).setOffset(0, 15); renderer.addBreak(0, 2, blue); renderer.addBreak(2, 201, green); renderer.addBreak(200, 10001, red); clusterLayer.setRenderer(renderer); map.addLayer(clusterLayer); // close the info window when the map is clicked dojo.connect(map, "onClick", cleanUp); // close the info window when esc is pressed dojo.connect(map, "onKeyDown", function(e) { if ( e.keyCode == 27 ) { cleanUp(); } }); } function cleanUp() { map.infoWindow.hide(); clusterLayer.clearSingles(); } function error(err) { console.log("something failed: ", err); } // show cluster extents function showExtents() { var extents = new esri.layers.GraphicsLayer(); var sym = new esri.symbol.SimpleFillSymbol().setColor(new dojo.Color([205,193,197,0.5])); dojo.forEach(clusterLayer._clusters, function(c) { var e = c.attributes.extent; extents.add(new esri.Graphic(new esri.geometry.Extent(e[0], e[1], e[2], e[3]), sym)); }, this); map.addLayer(extents, 0); } dojo.ready(init); As for the 4600 cutoff, I'm using a query from our database to populate the data - using a time range I can control the number of points rendered. The page works fine with 4583 points. When the query returns 4634, I get a blank screen, so the cutoff is somewhere right around 4600 - just not sure why... Thanks! Dave
... View more
07-25-2012
05:06 AM
|
0
|
0
|
1188
|
POST
|
I have a similar problem, in that I have just over 5000 points to plot on a map of the world - I am clustering them, though (using the code from the point clustering example in the JavaScript API). My issue is that it works just fine, up until 4600 points - any more, and the map simply doesn't draw. Any ideas as to why that might be?
... View more
07-24-2012
12:19 PM
|
0
|
0
|
1188
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|