Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
- <title>Create circles</title>
- <link rel="stylesheet" href="https://js.arcgis.com/3.17/esri/css/esri.css">
- <style>
- html,
- body,
- #map {
- height: 100%;
- width: 100%;
- margin: 0;
- padding: 0;
- }
- #controls {
- background: #fff;
- box-shadow: 0 6px 6px -6px #999;
- color: #444;
- font-family: sans-serif;
- height: auto;
- left: 1em;
- padding: 1em;
- position: absolute;
- top: 1em;
- width: auto;
- z-index: 40;
- }
- #controls div {
- padding: 0 0 1em 0;
- }
- </style>
- <script src="https://js.arcgis.com/3.17compact"></script>
- <script type="text/javascript" src="test.json"></script>
- <!-- <script src="skrypt.js"></script> -->
- <script>
- var map;
- var actual_JSON;
- function loadJSON(file, callback) {
- var xobj = new XMLHttpRequest();
- xobj.overrideMimeType("application/json");
- xobj.open('GET', file, true); // Replace 'my_data' with the path to your file
- xobj.onreadystatechange = function () {
- if (xobj.readyState == 4 && xobj.status == "200") {
- // Required use of an anonymous callback as .open will NOT return a value but simply returns undefined in asynchronous mode
- callback(xobj.responseText);
- }
- };
- xobj.send(null);
- }
- function load() {
- loadJSON("test.json", function(response) {
- actual_JSON = JSON.parse(response);
- console.log(actual_JSON.y);
- });
- }
- load();
- require([
- "esri/map", "esri/geometry/Extent", "esri/symbols/SimpleFillSymbol",
- "esri/graphic", "esri/layers/GraphicsLayer", "esri/Color",
- "esri/SpatialReference", "dojo/domReady!"
- ], function(
- Map, Extent, SimpleFillSymbol,
- Graphic, GraphicsLayer, Color,
- SpatialReference
- ) {
- map = new Map("map", {
- basemap: "gray",
- center: [22.741, 51.39],
- slider: false,
- zoom: 2
- });
- map.on("load", mapLoaded);
- function mapLoaded() {
- var gLayer = new GraphicsLayer({
- opacity: 0.7
- });
- var ext;
- var g;
- var r;
- var b;
- map.addLayer(gLayer);
- var x=[];
- var t=[];
- var y=[];
- var dzielnik=4;//zmienna zmniejszajaca ilosc punktow na mapie
- var ilosc=actual_JSON.x*actual_JSON.y/dzielnik;
- for(var i=0;i<ilosc;i++){//20000->50000
- y.push(actual_JSON.XLONG[i]);
- x.push(actual_JSON.XLAT[i]);
- t.push(actual_JSON.T2[i]);
- }
- var maksymalna = Math.max.apply(null, t);
- var minimalna = Math.min.apply(null, t);
- var licznik=maksymalna-minimalna;
- for(var i=0;i<ilosc;i++){//20000->50000
- //ext = new Extent(x[i],y[i],x[i]+0.1,y[i]+0.1, new SpatialReference({wkid:4326})) ;//extent(xpoczatkowy, ypoczatkowy, xkoncowy, ykoncowy)
- r=Math.round(255*((t[i]-minimalna)/licznik));//wystosowanie koloru
- b=255-r;//wystosowanie koloru
- g = new Graphic(Extent(x[i],y[i],x[i]+0.1,y[i]+0.1, new SpatialReference({wkid:4326})), new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID, null, new Color([r,0,b,1])));// kolor RGB
- gLayer.add(g);
- }
- }
- });
- </script>
- </head>
- <body>
- <div id="map"></div>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement