본문 바로가기

develop/web GIS

레이어 클릭시 이벤트 발생

map = new OpenLayers.Map('map',{

   projection: new OpenLayers.Projection("EPSG:900913"),

   displayProjection: new OpenLayers.Projection("EPSG:4326"),

   units: "m",

   tileSize : new OpenLayers.Size(256,256),

   numZoomLevels:19,

   allOverlays : true,

   eventListeners: {

       featureclick: function(e) {

        layerData(e);

       }

   },

   maxResolution: 156543.0339,

   tileOrigin : new OpenLayers.LonLat(-20037508.34, -20037508.34),

   restrictedExtent : new OpenLayers.Bounds(13596081.15422, 3759090.50573, 14784829.81794, 4982082.95812),

   maxExtent: new OpenLayers.Bounds(-20037508.34, -20037508.34, 20037508.34, 20037508.34),

   controls : []

   });


//이벤트 핸들

function layerData(e) {

var name = e.feature.attributes.Name;

var Country = e.feature.attributes.Country;

var City = e.feature.attributes.City;

var html = "";

    html += " <div id='divList' style='float:left; min-width: 200px; margin-left: 6px'>";

    html += "<b>Name : </b>"+name+"</BR>";

    html += "<b>Country : </b>"+Country+"</BR>";

    html += "<b>City : </b>"+City+"</BR>";

    html += "</div> ";

    $("#divList").html(html);

}