Skip to content

Commit 8ef5621

Browse files
committed
Cleaned up sample and data references
1 parent af5afde commit 8ef5621

File tree

3 files changed

+30
-27
lines changed

3 files changed

+30
-27
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ html, body, #mapDiv {
100100
});
101101
102102
map.on("load", function () {
103-
addGeoJsonLayer("http://myCorsEnabledServer.com/canada.geojson");
103+
addGeoJsonLayer("./data/dc-schools.json");
104104
});
105105
106106
// Add the layer

geojsonlayer.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
});
4848

4949
map.on("load", function () {
50-
addGeoJsonLayer("./data/dc-schools.json");
50+
addGeoJsonLayer("./data/dc-school-zones.json");
5151
});
5252

5353
function selectGeoJsonData(e) {
@@ -111,14 +111,14 @@ <h3 class="panel-title">ArcGIS GeoJSON Layer</h3>
111111
</button>
112112
</div>
113113
<div class="panel-body collapse in">
114-
<p>Load GeoJSON into the map as a GraphicsLayer. <a href="https://github.com/esri/Terraformer">Terraformer</a> converts all GeoJSON to ArcGIS JSON.</p>
114+
<p>Load GeoJSON into the map as a GraphicsLayer. Uses <a href="https://github.com/esri/Terraformer">Terraformer</a> to convert GeoJSON to ArcGIS JSON.</p>
115115
<div class="form text-left">
116116
<div class="form-group">
117117
<label class="control-label">Sample Data</label>
118118
<select class="form-control" id="selGeoJson">
119-
<option value="./data/dc-schools.json">GeoJSON File - D.C. Schools</option>
120-
<option value="./data/dc-bike-routes.json">GeoJSON File - D.C. Bike Routes</option>
121119
<option value="./data/dc-school-zones.json">GeoJSON File - D.C. School Zones</option>
120+
<option value="./data/dc-bike-routes.json">GeoJSON File - D.C. Bike Routes</option>
121+
<option value="./data/dc-schools.json">GeoJSON File - D.C. Schools</option>
122122
<option value="./data/canada.json">GeoJSON File - Canada</option>
123123
<option value="./data/usa.json">GeoJSON File - USA</option>
124124
<option value="http://koop.dc.esri.com/github/colemanm/hurricanes/fl_2004_hurricanes.json">Koop Server - Hurricanes</option>
@@ -127,8 +127,8 @@ <h3 class="panel-title">ArcGIS GeoJSON Layer</h3>
127127
</select>
128128
</div>
129129
<div class="form-group">
130-
<label class="control-label">URL <a target="_blank" href="https://developers.arcgis.com/javascript/jshelp/ags_proxy.html">(File or CORS Servers Only)</a></label>
131-
<input type="text" class="form-control" id="geoJsonUrl" value="http://opendata.dc.gov/datasets/81a9d9885947483aa2088d81b20bfe66_5.geojson" placeholder="http://opendata.dc.gov/datasets/81a9d9885947483aa2088d81b20bfe66_5.geojson">
130+
<label class="control-label">URL <a target="_blank" href="https://developers.arcgis.com/javascript/jshelp/ags_proxy.html">(Domain File/CORS Server)</a></label>
131+
<input type="text" class="form-control" id="geoJsonUrl" value="./data/dc-school-zones.json" placeholder="./data/dc-school-zones.json">
132132
</div>
133133
<div class="form-group text-center">
134134
<button id="btnAdd" class="btn btn-success">Add Your Data</button>

src/geojsonlayer.js

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -57,30 +57,35 @@ define([
5757
},
5858

5959
_setDefaultSymbols: function () {
60-
function getRandomColor(transparency) {
61-
var min = 50,
62-
max = 200;
63-
function getRandomInt() {
60+
function getRandomColor(mainColor, transparency) {
61+
function getRandomInt(min, max) {
6462
return Math.floor(Math.random() * (max - min + 1)) + min;
6563
}
66-
return new Color([getRandomInt(), getRandomInt(), getRandomInt(), transparency]);
64+
switch (mainColor) {
65+
case "red":
66+
return new Color([getRandomInt(150, 255), getRandomInt(0, 255), getRandomInt(0, 255), transparency]);
67+
case "green":
68+
return new Color([getRandomInt(0, 155), getRandomInt(150, 255), getRandomInt(0, 155), transparency]);
69+
case "blue":
70+
return new Color([getRandomInt(0, 255), getRandomInt(0, 255), getRandomInt(150, 255), transparency]);
71+
}
6772
}
68-
// Random colors - TODO: These color suck!
69-
this._simplePointSym = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, 14,
70-
new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, getRandomColor(0.75), 0.5),
71-
getRandomColor(0.85));
72-
this._simpleLineSym = new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([50, 50, 50, 0.75]), 2);
73+
// Random colors
74+
this._simplePointSym = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, 8,
75+
new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, getRandomColor("blue", 0.5), 1),
76+
getRandomColor("blue", 0.75));
77+
this._simpleLineSym = new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, getRandomColor("red", 0.9), 1);
7378
this._simplePolygonSym = new SimpleFillSymbol("solid",
74-
new SimpleLineSymbol("solid", new Color([50, 50, 50, 0.25]), 1),
75-
getRandomColor(0.25));
79+
new SimpleLineSymbol("solid", new Color([50, 50, 50, 0.15]), 1),
80+
getRandomColor("green", 0.15));
7681
// Option to hardcod colors here
7782
// this._simplePointSym = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, 10,
78-
// new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([50, 50, 150]), 0.5),
79-
// new Color([0, 50, 150, 0.25]));
80-
// this._simpleLineSym = new SimpleLineSymbol("solid", new Color([255, 50, 50, 1]), 2);
83+
// new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([150, 150, 150]), 0.75),
84+
// new Color([50, 130, 255, 0.75]));
85+
// this._simpleLineSym = new SimpleLineSymbol("solid", new Color([255, 50, 50, 0.65]), 2);
8186
// this._simplePolygonSym = new SimpleFillSymbol("solid",
82-
// new SimpleLineSymbol("solid", new Color([0, 0, 0, 0.25]), 1),
83-
// new Color([50, 150, 50, 0.5]));
87+
// new SimpleLineSymbol("solid", new Color([0, 0, 0, 0.15]), 1),
88+
// new Color([150, 255, 150, 0.10]));
8489
},
8590

8691
_setCorsSevers: function () {
@@ -243,7 +248,7 @@ define([
243248
_addGraphicToLayer: function (graphic) {
244249
// Add or project and then add graphic
245250
if (this._inSpatialReference.wkid === 4326 || this._inSpatialReference.wkid === 102100) {
246-
// API automatically translates between these for us, but map might not be in 102100!
251+
// ArcGIS API automatically translates between these!
247252
// if (graphic.geometry.spatialReference.wkid === 4326) {
248253
// graphic.setGeometry(webMercatorUtils.geographicToWebMercator(graphic.geometry));
249254
// }
@@ -275,8 +280,6 @@ define([
275280
this._drawCountTotal = arcgisJson.length;
276281
}
277282
// Add graphics to the layer with symbols, project if needed
278-
// NOTE: We could probably send a single batch request to the Geometry Server
279-
// but we'd have to re-attach all geometries to graphics. Maybe version 0.2...
280283
for (i = 0; i < this._drawCountTotal; i++) {
281284
feature = arcgisJson[i];
282285
// Create graphic - magically sets the geometry type!

0 commit comments

Comments
 (0)