| 1 |
<html> |
| 2 |
<head profile="http://www.w3.org/2002/12/namespace"> |
| 3 |
|
| 4 |
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> |
| 5 |
<meta name="GENERATOR" |
| 6 |
content="Rational Application Developer Standard Edition for WebSphere Software"> |
| 7 |
<meta name="viewport" content="user-scalable=no, width=device-width" /> |
| 8 |
|
| 9 |
<link rel="stylesheet" type="text/css" href="../../../../../dijit/themes/dijit.css"> |
| 10 |
<link rel="stylesheet" type="text/css" href="../../../../../dijit/themes/tundra/tundra.css"> |
| 11 |
|
| 12 |
<title>JSON Import</title> |
| 13 |
|
| 14 |
|
| 15 |
<script type="text/javascript" src="http://openlayers.org/api/2.10/OpenLayers.js"></script> |
| 16 |
|
| 17 |
<script type="text/javascript" src="../../../../../dojo/dojo.js"></script> |
| 18 |
|
| 19 |
<script type="text/javascript"> |
| 20 |
require([ "dojo/ready", |
| 21 |
"dojo/_base/lang", |
| 22 |
"dojox/geo/openlayers/Map", |
| 23 |
"dojox/geo/openlayers/Layer", |
| 24 |
"dojox/geo/openlayers/GfxLayer", |
| 25 |
"dojox/geo/openlayers/JsonImport"], function(ready, lang, Map, Layer, GfxLayer, JsonImport){ |
| 26 |
|
| 27 |
var map; |
| 28 |
|
| 29 |
ready(function(){ |
| 30 |
var options = { |
| 31 |
baseLayerName : "TheMap" |
| 32 |
}; |
| 33 |
|
| 34 |
map = new Map("map", options); |
| 35 |
|
| 36 |
loadJsonMap(); |
| 37 |
|
| 38 |
map.fitTo([-160, 70, 160, -70]); |
| 39 |
|
| 40 |
}); |
| 41 |
|
| 42 |
function loadJsonMap(){ |
| 43 |
|
| 44 |
layer = new GfxLayer("GfxLayer"); |
| 45 |
map.addLayer(layer); |
| 46 |
|
| 47 |
var cmc = new JsonImport({ |
| 48 |
url : 'ContinentalEurope.json', |
| 49 |
nextFeature : lang.hitch(this, function(f){ |
| 50 |
f.setStroke([ Math.floor(Math.random() * 255), |
| 51 |
Math.floor(Math.random() * 255), |
| 52 |
Math.floor(Math.random() * 255)]); |
| 53 |
var c = [ Math.floor(Math.random() * 255), |
| 54 |
Math.floor(Math.random() * 255), |
| 55 |
Math.floor(Math.random() * 255), |
| 56 |
0.5]; |
| 57 |
f.setFill(c); |
| 58 |
layer.addFeature(f); |
| 59 |
}), |
| 60 |
complete : lang.hitch(this, function(){ |
| 61 |
layer.redraw(); |
| 62 |
}) |
| 63 |
}); |
| 64 |
cmc.loadData(); |
| 65 |
}; |
| 66 |
}); |
| 67 |
</script> |
| 68 |
|
| 69 |
</head> |
| 70 |
<body class="tundra"> |
| 71 |
</head> |
| 72 |
|
| 73 |
<div id="map" style="background-color: #b5d0d0; width: 100%; height: 100%;"></div> |
| 74 |
|
| 75 |
</body> |
| 76 |
</html> |