-
Notifications
You must be signed in to change notification settings - Fork 0
/
esc_rur_sem_bl.php
167 lines (136 loc) · 5.17 KB
/
esc_rur_sem_bl.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<!DOCTYPE html>
<html lang="pt-br">
<head>
<title> CRR </title>
<meta charset="UTF-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
<link type="text/css" rel="stylesheet" href="stylesheet.css"/>
<script src="jquery-3.0.0.js" ></script>
<link type="text/css" rel="stylesheet" href="arcgis_main.css">
<script src="arcgisjs.js"></script>
<script src="//npmcdn.com/angular-esri-map@2"></script>
<script src="//ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/dojo.js" data-dojo-config="async: true"></script>
</head>
<body id="body">
<script>
var h = document.createElement("h2");
h.appendChild( document.createTextNode("Escolas rurais sem Banda Larga") );
document.body.appendChild(h);
var div = document.createElement("div");
div.setAttribute("id", "viewDiv");
require([
"esri/Map",
"esri/views/MapView", // SceneView
"esri/layers/Layer",
"dojo/domReady!"
], function(Map, MapView, Layer) {
var map = new Map({
basemap: "gray" // streets, topo, satellite, gray
});
// insere o mapa
var view = new MapView({
container: "viewDiv", // Reference to the DOM node that will contain the view
map: map, // References the map object created in step 3
zoom: 5, // Sets the zoom level based on level of detail (LOD)
center: [-55, -15] // Sets the center point of view in lon/lat
});
// insere a camada
Layer.fromPortalItem({
portalItem: { // autocast as esri/portal/PortalItem
id: "36aecf5a74af43d0b79f3b78a340f5cd"
}
}).then(addLayer).otherwise(rejection);
// Adds the layer to the map once it loads
function addLayer(lyr) {
map.add(lyr);
//alert("Layer added");
}
function rejection(err) {
alert("Layer failed to load: " + err);
}
});
document.body.appendChild(div);
$.ajax({
url:'esc_rur_sem_bl_bd.php',
complete: function (response) {
fncMunicipios(response.responseText);
},
error: function () {
alert('Error');
}
});
function fncMunicipios(response){
var res = response.split("#");
var sz = res.length;
var i=0;
var columns = 4;
var qtd = (sz-1)/columns;
// cria elementos html
var table = document.createElement("table");
var tbody = document.createElement("tbody");
var center = document.createElement("center");
var div = document.createElement("div");
var br = document.createElement("p");
// atribui id aos elementos criados
center.setAttribute('id', 'center');
table.setAttribute('id','table');
div.setAttribute('id','div');
// total de resultados
div.appendChild(br);
var p = document.createElement("p");
p.setAttribute('id','para');
p.appendChild( document.createTextNode("Total de resultados: " + qtd) );
div.appendChild(p);
div.appendChild(br);
// Indices da tabela
var tr = document.createElement("tr");
tr.setAttribute('id', 'tr');
var th = document.createElement("th");
th.appendChild(document.createTextNode( "Código IBGE" ));
tr.appendChild(th);
var th = document.createElement("th");
th.appendChild(document.createTextNode( "Município" ));
tr.appendChild(th);
var th = document.createElement("th");
th.appendChild(document.createTextNode( "Estado" ));
tr.appendChild(th);
var th = document.createElement("th");
th.appendChild(document.createTextNode( "Número de Escolas" ));
tr.appendChild(th);
tbody.appendChild(tr);
// monta a tabela html
while( i<(sz-2) ){
var tr = document.createElement("tr");
var td = document.createElement("td");
td.appendChild(document.createTextNode( res[i] ));
tr.appendChild(td);
i++;
var td = document.createElement("td");
td.appendChild(document.createTextNode( res[i] ));
tr.appendChild(td);
i++;
var td = document.createElement("td");
td.appendChild(document.createTextNode( res[i] ));
tr.appendChild(td);
i++;
var td = document.createElement("td");
td.appendChild(document.createTextNode( res[i] ));
tr.appendChild(td);
i++;
tbody.appendChild(tr);
}
table.appendChild(tbody);
center.appendChild(table);
div.appendChild(center);
div.appendChild(br);
document.body.appendChild(div);
// adiciona um rodapé na página (se necessario)
var p = document.createElement("p");
p.appendChild( document.createTextNode("* Dados de") );
document.body.appendChild(p);
}
</script>
</body>
</html>