Advertisement
Guest User

Untitled

a guest
Apr 15th, 2017
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 3.38 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3.  
  4. <head>
  5.   <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  6.   <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
  7.   <title>Create circles</title>
  8.   <link rel="stylesheet" href="https://js.arcgis.com/3.17/esri/css/esri.css">
  9.   <style>
  10.     html,
  11.     body,
  12.     #map {
  13.       height: 100%;
  14.       width: 100%;
  15.       margin: 0;
  16.       padding: 0;
  17.     }
  18.  
  19.     #controls {
  20.       background: #fff;
  21.       box-shadow: 0 6px 6px -6px #999;
  22.       color: #444;
  23.       font-family: sans-serif;
  24.       height: auto;
  25.       left: 1em;
  26.       padding: 1em;
  27.       position: absolute;
  28.       top: 1em;
  29.       width: auto;
  30.       z-index: 40;
  31.     }
  32.  
  33.     #controls div {
  34.       padding: 0 0 1em 0;
  35.     }
  36.   </style>
  37.  
  38.   <script src="https://js.arcgis.com/3.17compact"></script>
  39.   <script type="text/javascript" src="test.json"></script>
  40.   <!-- <script src="skrypt.js"></script> -->
  41.   <script>
  42.     var map;
  43.  
  44. var actual_JSON;
  45. function loadJSON(file, callback) {  
  46.  
  47.     var xobj = new XMLHttpRequest();
  48.     xobj.overrideMimeType("application/json");
  49.     xobj.open('GET', file, true); // Replace 'my_data' with the path to your file
  50.     xobj.onreadystatechange = function () {
  51.           if (xobj.readyState == 4 && xobj.status == "200") {
  52.            // Required use of an anonymous callback as .open will NOT return a value but simply returns undefined in asynchronous mode
  53.            callback(xobj.responseText);
  54.           }
  55.     };
  56.     xobj.send(null);  
  57.  }
  58.  
  59. function load() {
  60.    
  61.     loadJSON("test.json", function(response) {
  62.  
  63.         actual_JSON = JSON.parse(response);
  64.         console.log(actual_JSON.y);
  65.     });
  66. }
  67. load();
  68.  
  69.     require([
  70.       "esri/map", "esri/geometry/Extent", "esri/symbols/SimpleFillSymbol",
  71.       "esri/graphic", "esri/layers/GraphicsLayer", "esri/Color",
  72.       "esri/SpatialReference", "dojo/domReady!"
  73.     ], function(
  74.       Map, Extent, SimpleFillSymbol,
  75.       Graphic, GraphicsLayer, Color,
  76.       SpatialReference
  77.     ) {
  78.       map = new Map("map", {
  79.         basemap: "gray",
  80.         center: [22.741, 51.39],
  81.         slider: false,
  82.         zoom: 2
  83.       });
  84.       map.on("load", mapLoaded);
  85.       function mapLoaded() {
  86.         var gLayer = new GraphicsLayer({
  87.           opacity: 0.7
  88.         });
  89.         var ext;
  90.         var g;
  91.         var r;
  92.         var b;
  93.         map.addLayer(gLayer);
  94.         var x=[];
  95.         var t=[];
  96.         var y=[];
  97.         var dzielnik=4;//zmienna zmniejszajaca ilosc punktow na mapie
  98.         var ilosc=actual_JSON.x*actual_JSON.y/dzielnik;
  99.         for(var i=0;i<ilosc;i++){//20000->50000
  100.             y.push(actual_JSON.XLONG[i]);
  101.             x.push(actual_JSON.XLAT[i]);
  102.             t.push(actual_JSON.T2[i]);
  103.         }
  104.         var maksymalna = Math.max.apply(null, t);
  105.         var minimalna =  Math.min.apply(null, t);
  106.         var licznik=maksymalna-minimalna;
  107.         for(var i=0;i<ilosc;i++){//20000->50000
  108.         //ext = new Extent(x[i],y[i],x[i]+0.1,y[i]+0.1, new SpatialReference({wkid:4326})) ;//extent(xpoczatkowy, ypoczatkowy, xkoncowy, ykoncowy)
  109.         r=Math.round(255*((t[i]-minimalna)/licznik));//wystosowanie koloru
  110.         b=255-r;//wystosowanie koloru
  111.         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
  112.         gLayer.add(g);
  113.         }
  114.       }
  115.     });
  116.   </script>
  117. </head>
  118.  
  119. <body>
  120.   <div id="map"></div>
  121.   </div>
  122. </body>
  123.  
  124. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement