/** * @file map_poi.js * @version 20170906 ms * @type JS * @use map.js, internet.js * * Erweiterung für map.js zur Darstellung von "POI"-Overlays * benötigt: map.js, internet.js */ /** * @extends class KMap in map.js */ KMap.prototype.PoiMode=2; // 1 normal, 2 raster, 3 cluster KMap.prototype.PoiSize=16; KMap.prototype.PoiDist=18; KMap.prototype.PoiSnapDist=24; KMap.prototype.PoiSymbol={}; KMap.prototype.pois=[]; KMap.prototype.PoiClusterRadius=24; KMap.prototype.PoiClusterColor="rgba(241,149,59,.8)"; KMap.prototype.PoiClusterSymSize=24; KMap.prototype.PoiClusterFont="normal bold 14px sans-serif"; KMap.prototype.PoiClusterFontColor="rgb(255,255,255)"; KMap.prototype.PoiMaxTipNum=50; KMap.prototype.PoiTileSize=512; KMap.prototype.PoiTileSizeOverflow=0; KMap.prototype.PoiTiles=[]; KMap.prototype.PoiV=[]; KMap.prototype.PoiClusters=[]; KMap.prototype.PoiStaticShapes=[]; KMap.prototype.PoiFilterShapes=[]; KMap.prototype.PoiPlane=null; //KMap.prototype.PoiNumImgPlanes=0; KMap.prototype.PoiCanvas=null; KMap.prototype.PoiCtx=null; /* Required tags of one poi record: id,x,y,prior,type,symbol Optional tags of one poi record: fix,text,shp */ KMap.prototype.PoiPutTile=function(id,recs){ this.PoiTileRemove(id); this.pois.push({"id":id,"recs":recs}); if(!this.Dragging) this.PoiDrawPois(); } KMap.PoiSort=function(a,b){ return b.prior-a.prior; } KMap.prototype.PoiPlaceInRaster=function(tt){ for(var a=0;a-1){ c=this.PoiClusters[i]; c.pois.push(t); c.sx+=t.xx;c.sy+=t.yy; c.x=c.sx/c.pois.length;c.y=c.sy/c.pois.length; }else this.PoiClusters.push({pois:[t],x:t.xx,y:t.yy,sx:t.xx,sy:t.yy}); } KMap.prototype.PoiDissolveClusters=function(){ for(var a=this.PoiClusters.length-1;a>0;a--){ var c1=this.PoiClusters[a]; var dmin=this.PoiClusterRadius,i=-1; for(var b=0;b-1){ //merge clusters var r=this.PoiClusters[i]; r.pois=r.pois.concat(c1.pois); r.sx+=c1.sx;r.sy+=c1.sy; r.x=r.sx/r.pois.length;r.y=r.sy/r.pois.length; this.PoiClusters.splice(a,1); } } for(a=this.PoiClusters.length-1;a>=0;a--) if(this.PoiClusters[a].pois.length==1){this.PoiV.push(this.PoiClusters[a].pois[0]);this.PoiClusters.splice(a,1);} } KMap.prototype.PoiDrawPois=function(){ this.PoiV=[];this.PoiClusters=[];var poiShapes=[];var PoiIDs={};var tt=[]; var PoiShapesAdd = function(shp) { if(shp.sym) { for(var a = 0; a < shp.sym.length; a++) { var s = {type: shp.type, pts: shp.pts}; for(var key in shp.sym[a]) s[key] = shp.sym[a][key]; if(!s.z) s.z = 0; poiShapes.push(s); } } else poiShapes.push(shp); }; for(var a=0;a=0 && t.yy>=0 && t.xx=0 && t.my>=0 && t.mx=-this.PoiSnapDist && t.yy>=-this.PoiSnapDist && t.xx"+label.text+""; var l=document.createElement("div"); l.innerHTML=t; this.PoiPlane.appendChild(l); l.style.position="absolute"; //l.style.left=(x-l.offsetWidth/2)+"px"; l.style.left=(x+this.PoiSize/2+1)+"px"; l.style.top=(y-l.offsetHeight/2)+"px"; } KMap.PoiShpSort=function(a,b){ return a.z-b.z; } KMap.prototype.PoiDrawShp=function(shp){ if(shp.view && shp.view!="web") return; if(shp.type>1){ this.PoiCtx.beginPath(); for(var a=0;a0) return pois; // search clusters: for(a=0;a=0;i--){ var t=this.PoiTiles[i]; if(!KMap.ExtentsOverlap({xmin:t.kx*this.PoiTileSize*this.mpp,ymin:t.ky*this.PoiTileSize*this.mpp,xmax:(t.kx+1)*this.PoiTileSize*this.mpp,ymax:(t.ky+1)*this.PoiTileSize*this.mpp},this)){ //for(var b=0;b9 || Math.abs(this.my-this.ey)>9)) this.PoiDragging=true; if(this.PoiDragging){ //if(this.PoiDragPoi){ this.PoiMoveTo(this.PoiDragPoi,this.ex,this.ey); this.mapal.style.cursor="pointer"; //}else this.PoiDragging=false; //POI frame has been reloaded meanwhile } return this.PoiDragPoi?true:false; } KMap.prototype.PoiMouseDown=function(e){ var pois=this.PoiFind(this.ex,this.ey); if(pois.length==1 && pois[0].movable) this.PoiDragPoi=pois[0]; } KMap.prototype.PoiMouseUp=function(e){ if(this.PoiDragging){ this.PoiDragging=false; var nx=this.xmin+this.ex*this.mpp; var ny=this.ymax-this.ey*this.mpp; if(this.PoiMoved(this.PoiDragPoi.id,nx,ny)){ for(var a=0;a