OpenMap.Layer.DynamicMarkerClient = OpenLayers.Class(OpenLayers.Layer.Markers, { layerId : "", singleTile : false, // isBaseLayer: false, // markers: null, // drawn: false, // markerId: [], isServerSide : false, legend : null, //각종 주제도 속성 ///// layerProperty : null, iconType : "Normal", disableFeatureIds : {}, //////////////////// getName : function() { return this.layerProperty.LAYER_NM; }, getLayerId : function() { return this.layerProperty.LAYER_ID; }, // projection:"EPSG:4326", // displayProjection:"EPSG:900913", initialize: function(options) { this.layerProperty = options.layerProperty; OpenLayers.Layer.Markers.prototype.initialize.apply(this, arguments); this.layerId = options.layerProperty.LAYER_ID; this.singleTile = options.singleTile || false;// ? options.singleTile : false, // this.isBaseLayer = options.isBaseLayer || false; }, //CLASS_NAME: "OpenLayers.Layer.Markers", CLASS_NAME: "OpenMap.Layer.DynamicMarkerClient", setProperty: function(property) { this.property = property; this.events.triggerEvent('propertychanged', {layer:this}); }, //initialize icons for zoom level // initIcon : function(marker){ // //small icon // marker.miniIcon = { // url : OpenMap.Config.imgBaseUrl+'entypo_braceright.svg?fill='+marker.columns.MINICOLOR+'&size=10', // size : new OpenLayers.Size(10, 10) // }; // //big icon // marker.bigIcon = { // url : marker.icon.url, // size : new OpenLayers.Size(marker.icon.size.h, marker.icon.size.w) // }; // }, // setMap: function(map) { OpenLayers.Layer.Markers.prototype.setMap.apply(this, arguments); this.loadData(); this.refreshMarkers(); this.registerZoomEvent(); }, refreshMarkers : function(event){ // for(var i=0; i< this.markers.length;i++){ // if(this.markers[i].columns.MINILEVEL > this.map.getResolution()){ //icon // this.markers[i].icon.setSize(this.markers[i].bigIcon.size); // this.markers[i].icon.setUrl(this.markers[i].bigIcon.url); // }else{ //mini circle // this.markers[i].icon.setSize(this.markers[i].miniIcon.size); // this.markers[i].icon.setUrl(this.markers[i].miniIcon.url); // } // } // if(this.layerProperty.MINI_MPP > this.map.getResolution()){ //icon // var size = this.layerProperty.MATRIX_JSON[0][0].shapeSize; // var color = this.layerProperty.MATRIX_JSON[0][0].shapeFill; // var imageName = this.layerProperty.MATRIX_JSON[0][0].shapeUrl; // var imageUrl = OpenMap.Config.imgBaseUrl+imageName+'.svg?fill='+color+'&size='+size; // for(var i=0; i< this.markers.length;i++){ // this.markers[i].icon.setSize(new OpenLayers.Size(size, size)); // this.markers[i].icon.setUrl(imageUrl); // } // }else{ //mini circle // var color = this.layerProperty.MATRIX_JSON[0][0].miniColor; // for(var i=0; i< this.markers.length;i++){ // this.markers[i].icon.setSize(new OpenLayers.Size(10, 10)); // this.markers[i].icon.setUrl(OpenMap.Config.imgBaseUrl+'entypo_braceright.svg?fill='+color+'&size=10'); // } // } if(this.layerProperty.MINI_MPP == undefined || this.layerProperty.MINI_MPP < 0 || this.layerProperty.MINI_MPP > this.map.getResolution()){ //icon if(this.iconType == "Normal") return; for(var i=0; i< this.markers.length;i++){ var itemInfo = this.legend.parseItem(this.markers[i],true); this.markers[i].icon.setSize(itemInfo.icon.size); this.markers[i].icon.setUrl(itemInfo.icon.url); } this.events.triggerEvent('propertychanged', {layer:this}); this.iconType = "Normal" }else{ //mini circle if(this.iconType == "Mini") return; for(var i=0; i< this.markers.length;i++){ var loc = this.legend.findItemLoc(this.markers[i]); var color = this.layerProperty.MATRIX_JSON[loc[0]][loc[1]].miniColor; if(color != undefined && color != ""){ this.markers[i].icon.setSize(new OpenLayers.Size(10, 10)); this.markers[i].icon.setUrl(OpenMap.Config.imgBaseUrl+'entypo_braceright.svg?fill='+color+'&size=10'); }else{ var itemInfo = this.legend.parseItem(this.markers[i],true); this.markers[i].icon.setSize(itemInfo.icon.size); this.markers[i].icon.setUrl(itemInfo.icon.url); } } this.events.triggerEvent('propertychanged', {layer:this}); this.iconType = "Mini" } }, removeMap: function(map) { this.unregisterZoomEvent(); OpenLayers.Layer.Markers.prototype.removeMap.apply(this, arguments); }, loadData: function() { this.legend = new MapLegend( {matrix: this.layerProperty.MATRIX_JSON ,cost: this.layerProperty.COST_JSON ,category: this.layerProperty.CATEGORY_JSON}); var params = { cmd: 'data', layer: this.layerProperty.LAYER_ID, minx: 0, miny: 0, maxx: 20000000, maxy: 20000000, zoom: 1 }; $.ajax({ url: OpenMap.Config.distUrl, context: this, cache: false, type: "GET", timeout:10000, dataType: "json", data: params, async: false, success: function(items) { for(var i = 0 ; i this.map.getResolutionForZoom(zoom)) // 일반. { var itemInfo = this.legend.parseItem(m,true); var loc = this.legend.findItemLoc(m); var color = this.layerProperty.MATRIX_JSON[loc[0]][loc[1]].miniColor; if(color != undefined && color != ""){ imageUrl = OpenMap.Config.imgBaseUrl+'entypo_braceright.svg?fill='+color+'&size=10'; }else{ imageUrl = itemInfo.icon.url; } } else // 작은 아이콘. { var itemInfo = this.legend.parseItem(m,true); imageUrl = itemInfo.icon.url; } var marker = { type : "image", opacity : this.opacity, imageUrl : imageUrl, points : [] }; markers[m.featureId] = marker; } // 마커 좌표 추가. markers[m.featureId].points.push(m.lonlat.lon,m.lonlat.lat); } var ret = []; // featureId 별로 정리했던 목록을 array로 변환후 리턴. for(var k in markers) { if(markers.hasOwnProperty(k)) ret.push(markers[k]); } return ret; } });