/** * Created by cp on 2016/8/25. */ var mapResoultion=[ 156543.03390625, 78271.516953125,39135.7584765625,19567.87923828125,9783.939619140625,4891.9698095703125 ,2445.9849047851562 ,1222.9924523925781,611.4962261962891,305.74811309814453,152.87405654907226,76.43702827453613,38.218514137268066,19.109257068634033, 9.554628534317017,4.777314267158508,2.388657133579254,1.194328566789627,0.5971642833948135,0.2985821416974068,0.1492910708487034,0.0746455354243517,0.0373227677121759]; import WKT from 'ol/format/WKT'; import Icon from 'ol/style/Icon'; import CircleStyle from 'ol/style/Circle'; import Style from 'ol/style/Style'; import Fill from 'ol/style/Fill'; import Stroke from 'ol/style/Stroke'; import Text from 'ol/style/Text'; import Circle from 'ol/geom/Circle'; import Feature from 'ol/Feature'; import {Tile as TileLayer, Vector as VectorLayer} from 'ol/layer'; import {OSM, Vector as VectorSource} from 'ol/source'; function BaseLayer(map,maxL,minL,layerName,vueThis){ var map =map; var obj={}; let layerId=layerName; var maxResolution=611.4962261962891; var minResolution=0.0373227677121759; if(mapResoultion[maxL]){ maxResolution=mapResoultion[maxL] } if(mapResoultion[minL]){ minResolution=mapResoultion[minL] } var pLayer; var pSource; //面的图层 pLayer=getLyaersByName(layerName) if(pLayer){ pSource=pLayer.getSource(); } if(!pLayer){ pSource = new VectorSource(); pLayer = new VectorLayer({ zIndex:10, id:layerName, source: pSource, minResolution:minResolution, maxResolution:maxResolution }); pLayer.set("name",layerName); map.addLayer(pLayer); } function clean(){ pSource.clear(); } obj.clean=clean; function getLayer(){ return pLayer; } obj.getLayer=getLayer; function addFeatureArr(dataArr){ $(dataArr).each(function(i,val) { addfeature(val); }); } obj.addFeatureArr=addFeatureArr; function getFeatureById(tempId){ var features=pSource.getFeatures(); var reArr=[]; for(var i=0;i maxResolution) { text = ''; } else if (type == 'hide') { text = ''; } else if (type == 'shorten') { text = text.trunc(12); } else if (type == 'wrap') { text = stringDivider(text, 16, '\n'); } return text; }; //判断图层是否存在 function getLyaersByName(layerName){ var arrGroup=map.getLayerGroup().getLayers().getArray(); for(var j=0;j