Changeset b8134aa in observatorio


Ignore:
Timestamp:
Oct 14, 2014, 6:05:59 PM (10 years ago)
Author:
Ing. Roldan Vargas <rvargas@…>
Branches:
master
Children:
fec5f77
Parents:
1e397ea
Message:

Se agrega listener que permite mostrar ventanas emergentes sobre las unidades económicas con detalles sobre las mismas

File:
1 edited

Legend:

Unmodified
Added
Removed
  • procesos/media/geocadena/js/cadena_productiva.js

    rd9aeac8 rb8134aa  
    8080
    8181
    82 // === SECCION QUE ESTABLECE LOS NODOS INVOLUCRADOS EN LA CADENA PRODUCTIVA
     82// === SECCION QUE ESTABLECE LAS UNIDADES ECONOMICAS INVOLUCRADAS EN LA CADENA PRODUCTIVA
     83var listeners = {
     84    // Cuando el objeto es seleccionado
     85    'featureselected':function(evt){
     86        var feature = evt.feature;
     87
     88        var msg = '';
     89        msg += "<b>Empresa: </b>"+feature.attributes['nombre']+"<br/>";
     90        if (typeof (feature.attributes['rif']) != "undefined" && feature.attributes['rif'] != null) {
     91            msg += "<b>R.I.F.: </b>"+feature.attributes['rif']+"<br/>";
     92        }
     93        msg += "<b>Coordenadas: </b>"+OpenLayers.LonLat.fromString(feature.geometry.toShortString())+"<br/>";
     94        if (typeof (feature.attributes['consume']) != "undefined" && feature.attributes['consume'] != null) {
     95            msg += "<b>Consume:</b>"+feature.attributes['consume']+"<br/>";
     96        }
     97        if (typeof (feature.attributes['produce']) != "undefined" && feature.attributes['produce'] != null) {
     98            msg += "<b>Produce:</b>"+feature.attributes['produce']+"<br/>";
     99        }
     100
     101        // Permite mostrar ventana emergente en cada marca dentro del mapa
     102        var popup = new OpenLayers.Popup.FramedCloud("Anchored",
     103            OpenLayers.LonLat.fromString(feature.geometry.toShortString()),
     104            null,
     105            msg,
     106            null,
     107            true
     108        );
     109        feature.popup = popup;
     110        mapa.addPopup(popup);
     111    },
     112    // Cuando el objeto es deseleccionado
     113    'featureunselected':function(evt){
     114        var feature = evt.feature;
     115        mapa.removePopup(feature.popup);
     116        feature.popup.destroy();
     117        feature.popup = null;
     118    }
     119};
    83120/// Establece el estilo por defecto de las Unidades Económicas en la cadena productiva
    84121var defaultStyle = new OpenLayers.Style({
     
    159196        format: new OpenLayers.Format.GeoJSON()
    160197    }),
    161     styleMap: styleMap
    162 });
     198    styleMap: styleMap,
     199    eventListeners: listeners
     200});
     201var selector = new OpenLayers.Control.SelectFeature(ue_point,{
     202    hover:true,
     203    autoActivate:true
     204});
     205
     206mapa.addControl(selector);
     207selector.activate();
    163208/// Establece la visibilidad de la capa por defecto
    164209ue_point.setVisibility(true);
Note: See TracChangeset for help on using the changeset viewer.