diff --git a/admin/admin.db b/admin/admin.db
index 79d31fe..0247711 100644
Binary files a/admin/admin.db and b/admin/admin.db differ
diff --git a/classesjs/classe_arvoredecamadas.js b/classesjs/classe_arvoredecamadas.js
index 36808e3..5ea83b6 100644
--- a/classesjs/classe_arvoredecamadas.js
+++ b/classesjs/classe_arvoredecamadas.js
@@ -1201,6 +1201,18 @@ i3GEO.arvoreDeCamadas = {
// camadas", "i3geo");
var tnome, idtema = node.data.idopcoes, ltema = i3GEO.arvoreDeCamadas
.pegaTema(idtema), funcoes = i3GEO.arvoreDeCamadas.FUNCOES;
+
+
+ //
+ //ajusta as propriedades e funcoes caso a camada seja um plugin
+ //
+ ltema = i3GEO.pluginI3geo.aplicaPropriedades(ltema);
+ //inclui no objeto o parametro de verificacao
+ //e necessario clonar para nao alterar o original
+ funcoes = i3GEO.util.cloneObj(funcoes);
+ funcoes.plugini3geo = ltema.plugini3geo;
+ funcoes = i3GEO.pluginI3geo.aplicaPropriedades(funcoes);
+
if (funcoes.opacidade === true) {
tnome = "";
}
+ tema.AGUARDALEGENDA = i3GEO.arvoreDeCamadas.AGUARDALEGENDA;
+ //
+ //ajusta as propriedades conforme as caracteristicas de cada plugin
+ //verifica se o tema e do tipo plugin antes
+ //nao e necessario clonar
+ //
+ tema = i3GEO.pluginI3geo.aplicaPropriedades(tema);
//
// inclui icone indicando que o tema muda conforme a escala
//
@@ -1702,7 +1721,7 @@ i3GEO.arvoreDeCamadas = {
}
estilo = navm ? "cursor:move;vertical-align:35%;padding-top:0px;color:black;"
: "cursor:move;vertical-align:20%;color:black;";
- if (i3GEO.arvoreDeCamadas.AGUARDALEGENDA) {
+ if (tema.AGUARDALEGENDA) {
html += " 0) {
layers[0].setVisibility(obj.checked);
- if (obj.checked == true) {
- // foi necess�rio por causa de um bug no Firefox 27.0.1
- /*
- * @TODO verificar se persiste o erro nas versoes do FF
- */
- if (navn) {
- i3GEO.Interface.openlayers.atualizaTema("", obj.value);
- }
+ if(obj.checked === true){
+ layers[0].div.style.display = "block";
}
}
if (obj.checked) {
@@ -2582,7 +2583,7 @@ i3GEO.Interface = {
*/
PARAMETROSLAYER : "&TIPOIMAGEM=" + i3GEO.configura.tipoimagem,
/*
- * String acrescentada � url de cada tile para garantir a
+ * String acrescentada a url de cada tile para garantir a
* remoção do cache local
*
* Type: {string}
diff --git a/classesjs/classe_plugini3geo.js b/classesjs/classe_plugini3geo.js
index 045518b..cfcebfb 100644
--- a/classesjs/classe_plugini3geo.js
+++ b/classesjs/classe_plugini3geo.js
@@ -1,28 +1,28 @@
/**
* Title: pluginI3geo
- *
+ *
* i3GEO.pluginI3geo
- *
+ *
* Implementam os plugins do i3Geo que adicionam camadas especiais ao mapa,
* normalmente dados vetoriais.
- *
+ *
* Arquivo:
- *
+ *
* i3geo/classesjs/classe_plugini3geo.js
- *
+ *
* Licença:
- *
+ *
* GPL2
- *
+ *
* i3Geo Interface Integrada de Ferramentas de Geoprocessamento para Internet
- *
+ *
* Direitos Autorais Reservados (c) 2006 Ministério do Meio Ambiente
* Brasil Desenvolvedor: Edmar Moretti edmar.moretti@gmail.com
- *
+ *
* Este programa é software livre; você pode redistribuí-lo
* e/ou modificá-lo sob os termos da Licença Pública Geral
* GNU conforme publicada pela Free Software Foundation;
- *
+ *
* Este programa é distribuído na expectativa de que seja
* útil, porém, SEM NENHUMA GARANTIA; nem mesmo a garantia
* implícita de COMERCIABILIDADE OU ADEQUACÃO A UMA FINALIDADE
@@ -32,20 +32,19 @@
* não, escreva para a Free Software Foundation, Inc., no endereço
* 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA.
*/
-
if (typeof (i3GEO) === 'undefined') {
var i3GEO = {};
}
i3GEO.pluginI3geo = {
/**
* Inicia a execucao de um plugin
- *
+ *
* Camada e um objeto gerado pelo i3Geo quando uma camada e adicionada
* ao mapa O objeto i3GEO.arvoreDeCamadas.CAMADAS guarda todas as
* camadas adicionadas ao mapa Ao adicionar uma camada pelo catalogo, o
* i3Geo verifica se a camada possui plugin e direciona para ca Os
* plugins sao definidos como metadados em cada mapfile de cada tema
- *
+ *
* Veja em i3geo/classesphp/classe_mapa.php funcao parametrostemas
*/
inicia : function(camada) {
@@ -56,131 +55,175 @@ i3GEO.pluginI3geo = {
// para cada plugin deve haver um objeto com as funcoes especificas
// para
// cada interface
- i3GEO.pluginI3geo[camada.plugini3geo.plugin][i3GEO.Interface.ATUAL]
- .call(null, camada);
+ i3GEO.pluginI3geo[camada.plugini3geo.plugin][i3GEO.Interface.ATUAL].inicia(camada);
+ },
+ /**
+ * Aplica as propriedades em um objeto do tipo tema
+ *
+ * tema e fornecido por i3GEO.arvoreDeCamadas o ajuste das propriedades
+ * e necessario para que as propriedades aparecam de forma correta na
+ * arvore de camadas
+ */
+ aplicaPropriedades: function(camada){
+ if(camada.plugini3geo != ""){
+ camada = i3GEO.pluginI3geo[camada.plugini3geo.plugin][i3GEO.Interface.ATUAL].aplicaPropriedades(camada);
+ }
+ return camada;
},
/**
* Function: heatmap
- *
+ *
* Mapa de calor
- *
+ *
* Gera um layer do tipo mapa de calor e adiciona ao mapa
- *
+ *
* As dependências em javascript sao carregadas via script tag por
* meio de ferramentas/heatmap/openlayers_js.php
- *
+ *
* Esse programa também obtém os dados necessários
* ao plugin
- *
+ *
* O layer existente no mapfile deve conter um metadata chamado
* PLUGINI3GEO
- *
+ *
* Esse matadado deve conter uma string que será transformada em
* um objeto javascript para uso no plugin
- *
+ *
* Exemplo:
- *
+ *
* "PLUGINI3GEO" '{"plugin":"heatmap","parametros":{"coluna":"teste"}}'
- *
+ *
* Coluna é a que contém os dados numéricos que
* definem a quantidade de uma medida em cada ponto e é usada
* para gerar a representação. Se for vazia, considera-se
* o valor como 1
- *
+ *
* As cores das classes existentes no LAYER serão utilizadas para
* calcular as cores do mapa de calor. Se não existirem classes,
* será usado o default.
- *
+ *
*/
heatmap : {
- googlemaps: function(camada){
- var p = i3GEO.configura.locaplic
- + "/ferramentas/heatmap/googlemaps_js.php", carregaJs = "nao", crialayer;
- criaLayer = function() {
- var heatmap,pontos;
- heatmap = new HeatmapOverlay(i3GeoMap, {
- "radius":15,
- "visible":true,
- "opacity":60,
- "gradient": { 0.45: "rgb(0,0,255)", 0.55: "rgb(0,255,255)", 0.65: "rgb(0,255,0)", 0.95: "yellow", 1.0: "rgb(255,0,0)" },
- "legend": {
- "title": camada.tema,
- "position": "bl",
- "offset": [5,50]
- }
- });
- pontos={
- max: 10,
- data: heatmap_dados
+ googlemaps: {
+ aplicaPropriedades: function(camada){
+ return camada;
+ },
+ inicia: function(camada){
+ var p = i3GEO.configura.locaplic
+ + "/ferramentas/heatmap/googlemaps_js.php", carregaJs = "nao", crialayer;
+ criaLayer = function() {
+ var heatmap,pontos;
+ heatmap = new HeatmapOverlay(i3GeoMap, camada.name, {
+ "radius":15,
+ "visible":true,
+ "opacity":60,
+ "gradient": { 0.45: "rgb(0,0,255)", 0.55: "rgb(0,255,255)", 0.65: "rgb(0,255,0)", 0.95: "yellow", 1.0: "rgb(255,0,0)" },
+ "legend": {
+ "title": camada.tema,
+ "position": "bl",
+ "offset": [5,50]
+ }
+ });
+ i3GeoMap.overlayMapTypes.insertAt(0, heatmap);
+ pontos={
+ max: 10,
+ data: heatmap_dados
+ };
+ i3GEO.janela.fechaAguarde("aguardePlugin");
+ heatmap.setDataSet(pontos);
+ heatmap_dados = null;
+ // i3GeoMap.setZoom(i3GeoMap.getZoom());
};
- i3GEO.janela.fechaAguarde("aguardePlugin");
- heatmap.setDataSet(pontos);
- heatmap_dados = null;
- //i3GeoMap.setZoom(i3GeoMap.getZoom());
- };
- if (typeof (HeatmapOverlay) === 'undefined') {
- carregaJs = "sim";
+ if (typeof (HeatmapOverlay) === 'undefined') {
+ carregaJs = "sim";
+ }
+ p += "?carregajs=" + carregaJs + "&layer=" + camada.name
+ + "&coluna=" + camada.plugini3geo.parametros.coluna
+ + "&g_sid=" + i3GEO.configura.sid
+ + "&nomevariavel=heatmap_dados";
+ i3GEO.util.scriptTag(p, criaLayer,
+ "i3GEO.pluginI3geo.heatmap_script");
}
- p += "?carregajs=" + carregaJs + "&layer=" + camada.name
- + "&coluna=" + camada.plugini3geo.parametros.coluna
- + "&g_sid=" + i3GEO.configura.sid
- + "&nomevariavel=heatmap_dados";
- i3GEO.util.scriptTag(p, criaLayer,
- "i3GEO.pluginI3geo.heatmap_script");
},
- openlayers : function(camada) {
- var p = i3GEO.configura.locaplic
- + "/ferramentas/heatmap/openlayers_js.php", carregaJs = "nao", crialayer;
- criaLayer = function() {
- var heatmap, transformedTestData = { max: 10 , data: [] },
- data = heatmap_dados,
- datalen = heatmap_dados.length,
- nudata = [];
- // in order to use the OpenLayers Heatmap Layer we have to transform our data into
- // { max: , data: [{lonlat: , count: },...]}
- while(datalen--){
- nudata.push({
- lonlat: new OpenLayers.LonLat(data[datalen].lng, heatmap_dados[datalen].lat),
- count: heatmap_dados[datalen].count
- });
- }
- transformedTestData.data = nudata;
- // create our heatmap layer
- heatmap = new OpenLayers.Layer.Heatmap(
- camada.name,
- i3geoOL,
- i3geoOL.baseLayer,
- {
- visible: true,
- radius:10,
- "gradient": { 0.45: "rgb(0,0,255)", 0.55: "rgb(0,255,255)", 0.65: "rgb(0,255,0)", 0.95: "yellow", 1.0: "rgb(255,0,0)" },
- "legend": {
- "title": camada.tema,
- "position": "bl",
- "offset": [5,50]
+ openlayers : {
+ aplicaPropriedades: function(camada){
+ camada.sel = "nao";
+ camada.download = "nao";
+ camada.AGUARDALEGENDA = false;
+ camada.temporizador = "";
+ camada.copia = false;
+ camada.procurar = false;
+ camada.toponimia = false;
+ camada.etiquetas = false;
+ camada.tabela = false;
+ camada.grafico = false;
+ camada.destacar = false;
+ camada.wms = false;
+ camada.classe = "NAO";
+ return camada;
+ },
+ inicia: function(camada) {
+ var p = i3GEO.configura.locaplic
+ + "/ferramentas/heatmap/openlayers_js.php", carregaJs = "nao", crialayer;
+ criaLayer = function() {
+ var heatmap, transformedTestData = { max: 10 , data: [] },
+ data = heatmap_dados,
+ datalen = heatmap_dados.length,
+ nudata = [];
+ // in order to use the OpenLayers Heatmap Layer we have
+ // to
+ // transform our data into
+ // { max: , data: [{lonlat: ,
+ // count:
+ // },...]}
+ while(datalen--){
+ nudata.push({
+ lonlat: new OpenLayers.LonLat(data[datalen].lng, heatmap_dados[datalen].lat),
+ count: heatmap_dados[datalen].count
+ });
+ }
+ transformedTestData.data = nudata;
+ // create our heatmap layer
+ heatmap = new OpenLayers.Layer.Heatmap(
+ camada.name,
+ i3geoOL,
+ i3geoOL.baseLayer,
+ {
+ visible: true,
+ radius:10,
+ "gradient": { 0.45: "rgb(0,0,255)", 0.55: "rgb(0,255,255)", 0.65: "rgb(0,255,0)", 0.95: "yellow", 1.0: "rgb(255,0,0)" },
+ "legend": {
+ "title": camada.tema,
+ "position": "bl",
+ "offset": [5,50]
+ }
+ },
+ {
+ isBaseLayer: false,
+ opacity: 0.3,
+ projection: new OpenLayers.Projection("EPSG:4326")
}
- },
- {
- isBaseLayer: false,
- opacity: 0.3,
- projection: new OpenLayers.Projection("EPSG:4326")
- }
- );
- i3geoOL.addLayer(heatmap);
- heatmap.setDataSet(transformedTestData);
-
- heatmap_dados = null;
- i3GEO.janela.fechaAguarde("aguardePlugin");
- };
- if (typeof (HeatmapOverlay) === 'undefined') {
- carregaJs = "sim";
+ );
+ i3geoOL.addLayer(heatmap);
+ heatmap.setDataSet(transformedTestData);
+ heatmap_dados = null;
+ i3GEO.janela.fechaAguarde("aguardePlugin");
+ };
+ if (typeof (HeatmapOverlay) === 'undefined') {
+ carregaJs = "sim";
+ }
+ p += "?carregajs=" + carregaJs + "&layer=" + camada.name
+ + "&coluna=" + camada.plugini3geo.parametros.coluna
+ + "&g_sid=" + i3GEO.configura.sid
+ + "&nomevariavel=heatmap_dados";
+ i3GEO.util.scriptTag(p, criaLayer,
+ "i3GEO.pluginI3geo.heatmap_script");
+ }
+ },
+ googleearth: {
+ inicia: function(){
+ alert("Plugin nao disponivel");
}
- p += "?carregajs=" + carregaJs + "&layer=" + camada.name
- + "&coluna=" + camada.plugini3geo.parametros.coluna
- + "&g_sid=" + i3GEO.configura.sid
- + "&nomevariavel=heatmap_dados";
- i3GEO.util.scriptTag(p, criaLayer,
- "i3GEO.pluginI3geo.heatmap_script");
}
}
}
\ No newline at end of file
diff --git a/ferramentas/heatmap/googlemaps_js.php b/ferramentas/heatmap/googlemaps_js.php
index 9688d9f..be90c84 100644
--- a/ferramentas/heatmap/googlemaps_js.php
+++ b/ferramentas/heatmap/googlemaps_js.php
@@ -27,7 +27,8 @@ include_once($dir."/../../classesphp/classe_atributos.php");
$m = new Atributos($map_file,$layer);
$registros = $m->listaRegistrosXY($coluna, "brasil", "tudo");
-$n = count($registros);
+//TODO
+$n = 100;//count($registros);
$resultado = array();
if(empty($coluna)){
foreach($registros as $r){
diff --git a/ferramentas/heatmap/openlayers_js.php b/ferramentas/heatmap/openlayers_js.php
index 1440d6b..bd7436c 100644
--- a/ferramentas/heatmap/openlayers_js.php
+++ b/ferramentas/heatmap/openlayers_js.php
@@ -27,7 +27,8 @@ include_once($dir."/../../classesphp/classe_atributos.php");
$m = new Atributos($map_file,$layer);
$registros = $m->listaRegistrosXY($coluna, "brasil", "tudo");
-$n = count($registros);
+//TODO
+$n = 100;//count($registros);
$resultado = array();
if(empty($coluna)){
foreach($registros as $r){
diff --git a/pacotes/heatmap/src/heatmap-gmaps.js b/pacotes/heatmap/src/heatmap-gmaps.js
index 30ca720..6e016b4 100755
--- a/pacotes/heatmap/src/heatmap-gmaps.js
+++ b/pacotes/heatmap/src/heatmap-gmaps.js
@@ -6,172 +6,171 @@
* and the Beerware (http://en.wikipedia.org/wiki/Beerware) license.
*/
-//cria um layer idiota para poder calcular a projecao
+//i3GeoMapOverlay vem de i3GEO.Interface e e usado para calcular projecao
//http://stackoverflow.com/questions/1538681/how-to-call-fromlatlngtodivpixel-in-google-maps-api-v3
-heatmapFooOverlay.prototype = new google.maps.OverlayView();
-heatmapFooOverlay.prototype.onAdd = function() { }
-heatmapFooOverlay.prototype.onRemove = function() { }
-heatmapFooOverlay.prototype.draw = function() { }
-function heatmapFooOverlay() { this.setMap(i3GeoMap); }
-var heatmapBarOverlay = new heatmapFooOverlay();
-
-
-function HeatmapOverlay(map, cfg){
- var me = this;
-
- me.heatmap = null;
- me.conf = cfg;
- me.latlngs = [];
- me.bounds = null;
- me.setMap(map);
- google.maps.event.addListener(map, 'bounds_changed', function() { me.draw() });
+
+function HeatmapOverlay(map, name, cfg) {
+ var me = this;
+ me.name = name;
+ me.heatmap = null;
+ me.conf = cfg;
+ me.latlngs = [];
+ me.bounds = null;
+ me.setMap(map);
+ google.maps.event.addListener(map, 'bounds_changed', function() {
+ me.draw()
+ });
}
HeatmapOverlay.prototype = new google.maps.OverlayView();
-HeatmapOverlay.prototype.onAdd = function(){
+HeatmapOverlay.prototype.onAdd = function() {
- var panes = this.getPanes(),
- w = this.getMap().getDiv().clientWidth,
- h = this.getMap().getDiv().clientHeight,
- el = document.createElement("div");
+ var panes = this.getPanes(), w = this.getMap().getDiv().clientWidth, h = this
+ .getMap().getDiv().clientHeight, el = document.createElement("div");
- el.style.cssText = "position:absolute;top:0;left:0;width:"+w+"px;height:"+h+"px;";
+ el.style.cssText = "position:absolute;top:0;left:0;width:" + w
+ + "px;height:" + h + "px;";
- this.conf.element = el;
- panes.overlayLayer.appendChild(el);
+ this.conf.element = el;
+ panes.overlayLayer.appendChild(el);
- this.heatmap = h337.create(this.conf);
+ this.heatmap = h337.create(this.conf);
}
-HeatmapOverlay.prototype.onRemove = function(){
- // Empty for now.
+HeatmapOverlay.prototype.onRemove = function() {
+ // Empty for now.
}
-HeatmapOverlay.prototype.draw = function(){
-
- var me = this,
- overlayProjection = heatmapBarOverlay.getProjection(), //me.getProjection(),
- currentBounds = me.map.getBounds();
-
- if (currentBounds.equals(me.bounds)) {
- return;
- }
- me.bounds = currentBounds;
-
- var ne = overlayProjection.fromLatLngToDivPixel(currentBounds.getNorthEast()),
- sw = overlayProjection.fromLatLngToDivPixel(currentBounds.getSouthWest()),
- topY = ne.y,
- leftX = sw.x,
- h = sw.y - ne.y,
- w = ne.x - sw.x;
-
- me.conf.element.style.left = leftX + 'px';
- me.conf.element.style.top = topY + 'px';
- me.conf.element.style.width = w + 'px';
- me.conf.element.style.height = h + 'px';
- me.heatmap.store.get("heatmap").resize();
-
- if(this.latlngs.length > 0){
- this.heatmap.clear();
-
- var len = this.latlngs.length,
- projection = heatmapBarOverlay.getProjection(); //this.getProjection();
- d = {
- max: this.heatmap.store.max,
- data: []
- };
-
- while(len--){
- var latlng = this.latlngs[len].latlng;
- if(!currentBounds.contains(latlng)) { continue; }
-
- // DivPixel is pixel in overlay pixel coordinates... we need
- // to transform to screen coordinates so it'll match the canvas
- // which is continually repositioned to follow the screen.
- var divPixel = projection.fromLatLngToDivPixel(latlng),
- screenPixel = new google.maps.Point(divPixel.x - leftX, divPixel.y - topY);
-
- var roundedPoint = this.pixelTransform(screenPixel);
-
- d.data.push({
- x: roundedPoint.x,
- y: roundedPoint.y,
- count: this.latlngs[len].c
- });
- }
- this.heatmap.store.setDataSet(d);
- }
+HeatmapOverlay.prototype.draw = function() {
+
+ var me = this, overlayProjection = i3GeoMapOverlay.getProjection(), // me.getProjection(),
+ currentBounds = me.map.getBounds();
+
+ if (currentBounds.equals(me.bounds)) {
+ return;
+ }
+ me.bounds = currentBounds;
+
+ var ne = overlayProjection.fromLatLngToDivPixel(currentBounds
+ .getNorthEast()), sw = overlayProjection
+ .fromLatLngToDivPixel(currentBounds.getSouthWest()), topY = ne.y, leftX = sw.x, h = sw.y
+ - ne.y, w = ne.x - sw.x;
+
+ me.conf.element.style.left = leftX + 'px';
+ me.conf.element.style.top = topY + 'px';
+ me.conf.element.style.width = w + 'px';
+ me.conf.element.style.height = h + 'px';
+ me.heatmap.store.get("heatmap").resize();
+
+ if (this.latlngs.length > 0) {
+ this.heatmap.clear();
+
+ var len = this.latlngs.length, projection = i3GeoMapOverlay
+ .getProjection(); // this.getProjection();
+ d = {
+ max : this.heatmap.store.max,
+ data : []
+ };
+
+ while (len--) {
+ var latlng = this.latlngs[len].latlng;
+ if (!currentBounds.contains(latlng)) {
+ continue;
+ }
+
+ // DivPixel is pixel in overlay pixel coordinates... we need
+ // to transform to screen coordinates so it'll match the canvas
+ // which is continually repositioned to follow the screen.
+ var divPixel = projection.fromLatLngToDivPixel(latlng), screenPixel = new google.maps.Point(
+ divPixel.x - leftX, divPixel.y - topY);
+
+ var roundedPoint = this.pixelTransform(screenPixel);
+
+ d.data.push({
+ x : roundedPoint.x,
+ y : roundedPoint.y,
+ count : this.latlngs[len].c
+ });
+ }
+ this.heatmap.store.setDataSet(d);
+ }
}
-HeatmapOverlay.prototype.pixelTransform = function(p){
- var w = i3GEO.parametros.w,//this.heatmap.get("width"),
- h = i3GEO.parametros.h; //this.heatmap.get("height");
+HeatmapOverlay.prototype.pixelTransform = function(p) {
+ var w = i3GEO.parametros.w, // this.heatmap.get("width"),
+ h = i3GEO.parametros.h; // this.heatmap.get("height");
- while(p.x < 0){
- p.x+=w;
- }
+ while (p.x < 0) {
+ p.x += w;
+ }
- while(p.x > w){
- p.x-=w;
- }
+ while (p.x > w) {
+ p.x -= w;
+ }
- while(p.y < 0){
- p.y+=h;
- }
+ while (p.y < 0) {
+ p.y += h;
+ }
- while(p.y > h){
- p.y-=h;
- }
+ while (p.y > h) {
+ p.y -= h;
+ }
- p.x = (p.x >> 0);
- p.y = (p.y >> 0);
+ p.x = (p.x >> 0);
+ p.y = (p.y >> 0);
- return p;
+ return p;
}
-HeatmapOverlay.prototype.setDataSet = function(data){
-
- var me = this,
- currentBounds = me.map.getBounds(),
- mapdata = {
- max: data.max,
- data: []
- },
- d = data.data,
- dlen = d.length,
- projection = heatmapBarOverlay.getProjection(),//me.getProjection(),
- latlng, point;
-
- me.latlngs = [];
-
- while(dlen--){
- latlng = new google.maps.LatLng(d[dlen].lat, d[dlen].lng);
-
- if(!currentBounds.contains(latlng)) {
- continue;
- }
-
- me.latlngs.push({latlng: latlng, c: d[dlen].count});
- point = me.pixelTransform(projection.fromLatLngToDivPixel(latlng));
- mapdata.data.push({x: point.x, y: point.y, count: d[dlen].count});
- }
- if(me.heatmap){
+HeatmapOverlay.prototype.setDataSet = function(data) {
+
+ var me = this, currentBounds = me.map.getBounds(), mapdata = {
+ max : data.max,
+ data : []
+ }, d = data.data, dlen = d.length, projection = i3GeoMapOverlay
+ .getProjection(), // me.getProjection(),
+ latlng, point;
+
+ me.latlngs = [];
+
+ while (dlen--) {
+ latlng = new google.maps.LatLng(d[dlen].lat, d[dlen].lng);
+
+ if (!currentBounds.contains(latlng)) {
+ continue;
+ }
+
+ me.latlngs.push({
+ latlng : latlng,
+ c : d[dlen].count
+ });
+ point = me.pixelTransform(projection.fromLatLngToDivPixel(latlng));
+ mapdata.data.push({
+ x : point.x,
+ y : point.y,
+ count : d[dlen].count
+ });
+ }
+ if (me.heatmap) {
me.heatmap.clear();
- me.heatmap.store.setDataSet(mapdata);
+ me.heatmap.store.setDataSet(mapdata);
}
}
-HeatmapOverlay.prototype.addDataPoint = function(lat, lng, count){
+HeatmapOverlay.prototype.addDataPoint = function(lat, lng, count) {
- var projection = heatmapBarOverlay.getProjection(),//this.getProjection(),
- latlng = new google.maps.LatLng(lat, lng),
- point = this.pixelTransform(projection.fromLatLngToDivPixel(latlng));
+ var projection = i3GeoMapOverlay.getProjection(), // this.getProjection(),
+ latlng = new google.maps.LatLng(lat, lng), point = this
+ .pixelTransform(projection.fromLatLngToDivPixel(latlng));
- this.heatmap.store.addDataPoint(point.x, point.y, count);
- this.latlngs.push({ latlng: latlng, c: count });
+ this.heatmap.store.addDataPoint(point.x, point.y, count);
+ this.latlngs.push({
+ latlng : latlng,
+ c : count
+ });
}
-HeatmapOverlay.prototype.toggle = function(){
- this.heatmap.toggleDisplay();
+HeatmapOverlay.prototype.toggle = function() {
+ this.heatmap.toggleDisplay();
}
diff --git a/pacotes/heatmap/src/heatmap-openlayers.js b/pacotes/heatmap/src/heatmap-openlayers.js
index 0131a79..cf64d49 100755
--- a/pacotes/heatmap/src/heatmap-openlayers.js
+++ b/pacotes/heatmap/src/heatmap-openlayers.js
@@ -18,115 +18,134 @@ OpenLayers.Layer.Heatmap = OpenLayers.Class(OpenLayers.Layer, {
mapLayer: null,
// we store the lon lat data, because we have to redraw with new positions on zoomend|moveend
tmpData: {},
- initialize: function(name, map, mLayer, hmoptions, options){
- var heatdiv = document.createElement("div"),
- handler;
+ initialize: function(name, map, mLayer, hmoptions, options){
+ var heatdiv = document.createElement("div"),
+ handler;
- OpenLayers.Layer.prototype.initialize.apply(this, [name, options]);
+ OpenLayers.Layer.prototype.initialize.apply(this, [name, options]);
- heatdiv.style.cssText = "position:absolute;width:"+map.size.w+"px;height:"+map.size.h+"px;";
- // this will be the heatmaps element
- this.div.appendChild(heatdiv);
- // add to our heatmap.js config
- hmoptions.element = heatdiv;
- this.mapLayer = mLayer;
- this.map = map;
- // create the heatmap with passed heatmap-options
- this.heatmap = h337.create(hmoptions);
+ heatdiv.style.cssText = "position:absolute;width:"+map.size.w+"px;height:"+map.size.h+"px;";
+ // this will be the heatmaps element
+ this.div.appendChild(heatdiv);
+ // add to our heatmap.js config
+ hmoptions.element = heatdiv;
+ this.mapLayer = mLayer;
+ this.map = map;
+ // create the heatmap with passed heatmap-options
+ this.heatmap = h337.create(hmoptions);
- handler = function(){
- if(this.tmpData.max){
- this.updateLayer();
- }
- };
- // on zoomend and moveend we have to move the canvas element and redraw the datapoints with new positions
- map.events.register("zoomend", this, handler);
- map.events.register("moveend", this, handler);
- },
- updateLayer: function(){
- var pixelOffset = this.getPixelOffset(),
- el = this.heatmap.get('element');
- // if the pixeloffset e.g. for x was positive move the canvas element to the left by setting left:-offset.y px
- // otherwise move it the right by setting it a positive value. same for top
- el.style.top = ((pixelOffset.y > 0)?('-'+pixelOffset.y):(Math.abs(pixelOffset.y)))+'px';
- el.style.left = ((pixelOffset.x > 0)?('-'+pixelOffset.x):(Math.abs(pixelOffset.x)))+'px';
+ handler = function(){
+ if(this.tmpData.max){
+ this.updateLayer();
+ }
+ };
+ handler1 = function(){
+ if(this.tmpData.max){
+ this.toggle();
+ this.updateLayer();
+ }
+ };
- this.setDataSet(this.tmpData);
+ // on zoomend and moveend we have to move the canvas element and redraw the datapoints with new positions
+ //map.events.register("zoomend", this, handler);
+ map.events.register("moveend", this, handler);
+ this.events.register("visibilitychanged", this,handler1);
+ map.events.register(
+ "removed",
+ this,
+ function(){
+ if(this.tmpData.max){
+ this.destroy();
+ }
+ });
+ },
+ updateLayer: function(){
+ var pixelOffset = this.getPixelOffset(),
+ el = this.heatmap.get('element');
+ // if the pixeloffset e.g. for x was positive move the canvas element to the left by setting left:-offset.y px
+ // otherwise move it the right by setting it a positive value. same for top
+ el.style.top = ((pixelOffset.y > 0)?('-'+pixelOffset.y):(Math.abs(pixelOffset.y)))+'px';
+ el.style.left = ((pixelOffset.x > 0)?('-'+pixelOffset.x):(Math.abs(pixelOffset.x)))+'px';
+ //var p = el.parentNode.style;
+ //console.warn(p.display)
+ if(this.visibility === true){
+ this.setDataSet(this.tmpData);
+ }
},
- getPixelOffset: function () {
- var o = this.mapLayer.map.layerContainerOrigin,
- o_lonlat = new OpenLayers.LonLat(o.lon, o.lat),
- o_pixel = this.mapLayer.getViewPortPxFromLonLat(o_lonlat),
- c = this.mapLayer.map.center,
- c_lonlat = new OpenLayers.LonLat(c.lon, c.lat),
- c_pixel = this.mapLayer.getViewPortPxFromLonLat(c_lonlat);
+ getPixelOffset: function () {
+ var o = this.mapLayer.map.layerContainerOrigin,
+ o_lonlat = new OpenLayers.LonLat(o.lon, o.lat),
+ o_pixel = this.mapLayer.getViewPortPxFromLonLat(o_lonlat),
+ c = this.mapLayer.map.center,
+ c_lonlat = new OpenLayers.LonLat(c.lon, c.lat),
+ c_pixel = this.mapLayer.getViewPortPxFromLonLat(c_lonlat);
- return {
- x: o_pixel.x - c_pixel.x,
- y: o_pixel.y - c_pixel.y
- };
+ return {
+ x: o_pixel.x - c_pixel.x,
+ y: o_pixel.y - c_pixel.y
+ };
- },
+ },
setDataSet: function(obj){
- var set = {},
+ var set = {},
dataset = obj.data,
dlen = dataset.length,
- entry, lonlat, pixel;
+ entry, lonlat, pixel;
set.max = obj.max;
set.data = [];
// get the pixels for all the lonlat entries
- while(dlen--){
- entry = dataset[dlen],
- lonlat = entry.lonlat.clone().transform(this.projection, this.map.getProjectionObject()),
- pixel = this.roundPixels(this.getViewPortPxFromLonLat(lonlat));
-
- if(pixel){
- set.data.push({x: pixel.x, y: pixel.y, count: entry.count});
- }
- }
- this.tmpData = obj;
- this.heatmap.store.setDataSet(set);
+ while(dlen--){
+ entry = dataset[dlen],
+ lonlat = entry.lonlat.clone().transform(this.projection, this.map.getProjectionObject()),
+ pixel = this.roundPixels(this.getViewPortPxFromLonLat(lonlat));
+
+ if(pixel){
+ set.data.push({x: pixel.x, y: pixel.y, count: entry.count});
+ }
+ }
+ this.tmpData = obj;
+ this.heatmap.store.setDataSet(set);
},
// we don't want to have decimal numbers such as xxx.9813212 since they slow canvas performance down + don't look nice
roundPixels: function(p){
- if(p.x < 0 || p.y < 0){
- return false;
- }
-
- p.x = (p.x >> 0);
- p.y = (p.y >> 0);
-
- return p;
+ if(p.x < 0 || p.y < 0){
+ return false;
+ }
+
+ p.x = (p.x >> 0);
+ p.y = (p.y >> 0);
+
+ return p;
},
// same procedure as setDataSet
addDataPoint: function(lonlat){
- var pixel = this.roundPixels(this.mapLayer.getViewPortPxFromLonLat(lonlat)),
- entry = {lonlat: lonlat},
- args;
+ var pixel = this.roundPixels(this.mapLayer.getViewPortPxFromLonLat(lonlat)),
+ entry = {lonlat: lonlat},
+ args;
+
+ if(arguments.length == 2){
+ entry.count = arguments[1];
+ }
- if(arguments.length == 2){
- entry.count = arguments[1];
- }
+ this.tmpData.data.push(entry);
- this.tmpData.data.push(entry);
-
- if(pixel){
- args = [pixel.x, pixel.y];
+ if(pixel){
+ args = [pixel.x, pixel.y];
- if(arguments.length == 2){
- args.push(arguments[1]);
+ if(arguments.length == 2){
+ args.push(arguments[1]);
+ }
+ this.heatmap.store.addDataPoint.apply(this.heatmap.store, args);
}
- this.heatmap.store.addDataPoint.apply(this.heatmap.store, args);
- }
},
toggle: function(){
this.heatmap.toggleDisplay();
},
destroy: function() {
- // for now, nothing special to do here.
- OpenLayers.Layer.Grid.prototype.destroy.apply(this, arguments);
- },
+ // for now, nothing special to do here.
+ OpenLayers.Layer.Grid.prototype.destroy.apply(this, arguments);
+ },
CLASS_NAME: "OpenLayers.Layer.Heatmap"
});
--
libgit2 0.21.2