基于flash-marker.js 的地图标注闪烁代码调试

修改网上流传的flash-marker.js

(function (global, factory) {
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
    typeof define === 'function' && define.amd ? define(factory) :
      (global.FlashMarker = factory());
}(this, (function () { 'use strict';
  var map = null;
  var canvas = null;
  /**
   * @author lzugis
   * @Date 2017-09-29
   * */
  function CanvasLayer(options) {
    this.options = options || {};
    this.paneName = this.options.paneName || 'labelPane';
    this.zIndex = this.options.zIndex || 0;
    this._map = options.map;
    map = this._map;
    this._lastDrawTime = null;
    this.show();
  }

  CanvasLayer.prototype.initialize = function () {
    var map = this._map;
    canvas = this.canvas = document.createElement('canvas');
    var ctx = this.ctx = this.canvas.getContext('2d');
    canvas.style.cssText = 'position:absolute;' + 'left:0;' + 'top:0;' + 'z-index:' + this.zIndex + ';';
    this.adjustSize();
    this.adjustRatio(ctx);
    map.getViewport().appendChild(canvas);
    var that = this;
    map.getView().on('propertychange',function(){
      // $(canvas).hide();
      // canvas.style.display="none";
    });
    // map.on("moveend",function(){
    //   // $(canvas).show();
    //   // canvas.style.display="block";
    //   that.adjustSize();
    //   that._draw();
    // });
  };

  CanvasLayer.prototype.adjustSize = function () {
    var size = this._map.getSize();
    // var canvas = this.canvas;
    canvas.width = size[0];
    canvas.height = size[1];
    canvas.style.width = canvas.width + 'px';
    canvas.style.height = canvas.height + 'px';
  };

  CanvasLayer.prototype.adjustRatio = function (ctx) {
    var backingStore = ctx.backingStorePixelRatio || ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.msBackingStorePixelRatio || ctx.oBackingStorePixelRatio || ctx.backingStorePixelRatio || 1;
    var pixelRatio = (window.devicePixelRatio || 1) / backingStore;
    var canvasWidth = ctx.canvas.width;
    var canvasHeight = ctx.canvas.height;
    ctx.canvas.width = canvasWidth * pixelRatio;
    ctx.canvas.height = canvasHeight * pixelRatio;
    ctx.canvas.style.width = canvasWidth + 'px';
    ctx.canvas.style.height = canvasHeight + 'px';
    ctx.scale(pixelRatio, pixelRatio);
  };

  CanvasLayer.prototype.draw = function () {
    var self = this;
    var args = arguments;

    clearTimeout(self.timeoutID);
    self.timeoutID = setTimeout(function () {
      self._draw();
    }, 15);
  };

  CanvasLayer.prototype._draw = function () {
    var map = this._map;
    var size = map.getSize();
    var center = map.getView().getCenter();
    if (center) {
      var pixel = map.getPixelFromCoordinate(center);
      this.canvas.style.left = pixel[0] - size[0] / 2 + 'px';
      this.canvas.style.top = pixel[1] - size[1] / 2 + 'px';
      this.options.update && this.options.update.call(this);
    }
  };

  CanvasLayer.prototype.getContainer = function () {
    return this.canvas;
  };

  CanvasLayer.prototype.show = function () {
    this.initialize();
    this.canvas.style.display = 'block';
  };

  CanvasLayer.prototype.hide = function () {
    this.canvas.style.display = 'none';
  };

  CanvasLayer.prototype.setZIndex = function (zIndex) {
    this.canvas.style.zIndex = zIndex;
  };

  CanvasLayer.prototype.getZIndex = function () {
    return this.zIndex;
  };

  var global = typeof window === 'undefined' ? {} : window;

  var requestAnimationFrame = global.requestAnimationFrame || global.mozRequestAnimationFrame || global.webkitRequestAnimationFrame || global.msRequestAnimationFrame || function (callback) {
    return global.setTimeout(callback, 1000 / 60);
  };

  function Marker(opts) {
    this.city = opts.name;
    this.location = [opts.lnglat[0], opts.lnglat[1]];
    this.color = opts.color;
    this.type = opts.type || 'circle';
    this.speed = opts.speed || 0.15;
    this.size = 0;
    this.max = opts.max || 20;
  }

  Marker.prototype.draw = function (context) {
    context.save();
    context.beginPath();
    switch (this.type) {
      case 'circle':
        this._drawCircle(context);
        break;
      case 'ellipse':
        this._drawEllipse(context);
        break;
      default:
        break;
    }
    context.closePath();
    context.restore();

    this.size += this.speed;
    if (this.size > this.max) {
      this.size = 0;
    }
  };

  Marker.prototype._drawCircle = function (context) {
    var pixel = this.pixel||map.getPixelFromCoordinate(this.location);
    context.strokeStyle = this.color;
    context.moveTo(pixel[0] + pixel.size, pixel[1]);
    context.arc(pixel[0], pixel[1], this.size, 0, Math.PI * 2);
    context.stroke();
  };

  Marker.prototype._drawEllipse = function (context) {
    var pixel = this.pixel || map.getPixelFromCoordinate(this.location);
    var x = pixel[0],
      y = pixel[1],
      w = this.size,
      h = this.size / 2,
      kappa = 0.5522848,

      // control point offset horizontal
      ox = w / 2 * kappa,

      // control point offset vertical
      oy = h / 2 * kappa,

      // x-start
      xs = x - w / 2,

      // y-start
      ys = y - h / 2,

      // x-end
      xe = x + w / 2,

      // y-end
      ye = y + h / 2;

    context.strokeStyle = this.color;
    context.moveTo(xs, y);
    context.bezierCurveTo(xs, y - oy, x - ox, ys, x, ys);
    context.bezierCurveTo(x + ox, ys, xe, y - oy, xe, y);
    context.bezierCurveTo(xe, y + oy, x + ox, ye, x, ye);
    context.bezierCurveTo(x - ox, ye, xs, y + oy, xs, y);
    context.stroke();
  };

  function FlashMarker(map, dataSet) {
    this.timer = null;
    var that = this;
    var animationLayer = null,
      width = map.getSize()[0],
      height = map.getSize()[1],
      animationFlag = true,
      markers = [];
    that.width = width;
    that.height = height;
    this.close();

    var addMarker = function addMarker() {
      if (markers.length > 0) return;
      markers = [];
      for (var i = 0; i < dataSet.length; i++) {
        markers.push(new Marker(dataSet[i]));
      }
    };

    //上层canvas渲染,动画效果
    var render = function render() {
      var animationCtx = animationLayer.canvas.getContext('2d');
      that.animationCtx = animationCtx;
      if (!animationCtx) {
        return;
      }

      if (!animationFlag) {
        animationCtx.clearRect(0, 0, width, height);
        return;
      }

      addMarker();

      animationCtx.fillStyle = 'rgba(0,0,0,.95)';
      var prev = animationCtx.globalCompositeOperation;
      animationCtx.globalCompositeOperation = 'destination-in';
      animationCtx.fillRect(0, 0, width, height);
      animationCtx.globalCompositeOperation = prev;

      for (var i = 0; i < markers.length; i++) {
        var marker = markers[i];
        marker.draw(animationCtx);
      }
    };
    //初始化
    var init = function init() {
      animationLayer = new CanvasLayer({
        map: map,
        update: render
      });

      (function drawFrame() {
        that.timer = requestAnimationFrame(drawFrame);
        render();
      })();
    };

    init();
  }
  FlashMarker.prototype.close = function() {
    cancelAnimationFrame(this.timer);
    if(this.animationCtx){
      this.animationCtx.clearRect(0, 0, this.width, this.height);
    }
  }
  return FlashMarker;

})));

调用代码

  //数据
let lnglat=[];//坐标值[x,y]    
let citys = [{ name: '', lnglat: lnglat, color: '#5070FF', type: 'circle', speed: 0.5, }]; if(this.mark){ this.mark.close(); } this.mark = new window.FlashMarker(map, citys);

 

原文地址:https://www.cnblogs.com/webgis-mc/p/10455731.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


  译序:JWMediaPlayer是开源的网页使用的Flash播放器。本文采摘于JWPlayer的官方文档,讲解了JWPlayer对于RTMP的使用方法,我们可以从JWPlayer客户端的角度来了解RTMP协议。以下是官方原文:      简介    RTMP(RealTimeMessagingProtocol
    Flash编程原理都是只能将1写为0,而不能将0写成1.所以在Flash编程之前,必须将对应的块擦除,而擦除的过程就是将所有位都写为1的过程,块内的所有字节变为0xFF.因此可以说,编程是将相应位写0的过程,而擦除是将相应位写1的过程,两者的执行过程完全相反.一、Nor和NandFlash
 上传setenvgatewayip192.168.1.1;setenvserverip192.168.1.7;setenvipaddr192.168.1.156;mw.b0x820000000xff0x1000000sfprobe0sfread0x8200000000x1000000tftp0x82000000test.bin0x1000000 下载mw.b82000000ff1000000tftp82000000test.bi
Error:FlashDownloadFailed-"Cortex-M3"出现一般有两种情况:1.SWD模式下,Debug菜单中,Reset菜单选项(Autodetect/HWreset/sysresetReq/Vectreset)默认是AutoDetect,改成SysResetReq即可。2.Jtag模式下,主要是芯片大小选错。Flash->ConfigureFalshTools配置窗口,切换到“Utilities"
jPlayer是一个用于控制和播放mp3文件的jQuery插件。它在后台使用Flash来播放mp3文件,前台播放器外观完全可以使用XHML/CSS自定义。支持:有一点比较好的是,在支持html5的浏览器上会使用html5的标签audio或者video,而不支持的浏览器上使用swf来播放选择需要播放的Mp3文件。播放、暂停
#ifndef__FONTUPD_H__#define__FONTUPD_H__#include"sys.h" //字库信息结构体定义33字节__packedtypedefstruct{u8fontok;//字库存在标志,0XAA,字库正常;其他,字库不存在u32ugbkaddr;//unigbk的地址u32ugbksize;//unigbk的大小u32f12addr;//gbk12地址u32g
ROM(ReadOnlyMemory)和RAM(RandomAccessMemory)指的都是半导体存储器。ROM在系统停止供电的时候仍然可以保持数据,而RAM通常都是在掉电之后就丢失数据,但是访问速度快。典型的RAM就是计算机的内存。RAM有两大类,一种称为静态RAM(StaticRAM/SRAM),SRAM速度非常快,是目前读写最快的存储
JSpc端和移动端实现复制到剪贴板功能实现在网页上复制文本到剪切板,一般是使用JS+Flash结合的方法,网上有很多相关文章介绍。随着HTML5技术的发展,Flash已经在很多场合不适用了,甚至被屏蔽。本文介绍的一款JS插件,实现了纯JS方法复制文本到剪切板。插件名是Clipboard.js,该插件不依
例子:R0=1R1=1R2=10R3=e000ed10R12=0LR=fffffff9(中断返回值)PC=0PSR=60000013或60000016或60000036(Z、C、EXCEPT_NUM:RTC_WKUP_IRQn、EXTI0_IRQn、USART2_IRQn)BFAR=e000ed38(不关心)CFSR=20000(INVSTATE:Invalidstateusagefault thePCvaluestackedf
 内存接口概念首先来分析下操作GPIO控制器和操作UART控制器两者的区别如图是S3C2440是个片上系统,有GPIO控制器(接有GPIO管脚),有串口控制器(接有TXDRXD引脚)配置GPIO控制器相应的寄存器,即可让引脚输出高低电平;配置UART控制器相应的寄存器,即可让引脚输出波形。前者相对简单,类
小编导语:    近几年来,网页游戏成为了游戏界关注的焦点,由于其制作简单,成本低并且收益率较高,因此成为了众多游戏厂商追逐的对象,但是除了商家夸张的炒作宣传外,很少有页游佳作出现。然而,随着Unity3D游戏引擎的出现,网页游戏的3D化成了页游冲出重围的杀手锏,那么在flash网页游戏称
1.指定数组到特定的Flash单元#pragmalocation=0x000FFF00 __rootconstcharFlash_config[]={0x0,0x1,0x2,0x3,0x4,0x5,0x6,0x7,0x8,0x9,0xA,0xB,0xC,0xD,0xE,0xF,0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F,0x20,0x21,0x22,0x23,0
继续研究发现,计算机的固件真的很有趣。参考了一些重要的资料,比如http://donovan6000.blogspot.com/2013/06/insyde-bios-modding-advanced-and-power-tabs.html等,对于IDA的使用也了解了一些。最后,总结一下目前看来可行性的方案:0.基础知识储备,包括UEFIBIOS的概念,InsydeBIOS的
<!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><title>navigator对象<itle></head><body><buttononclick="checkFlash()">检测</button>
修改网上流传的flash-marker.js(function(global,factory){typeofexports==='object'&&typeofmodule!=='undefined'?module.exports=factory():typeofdefine==='function'&&define.amd?define(factory
shareObject本地缓存存储位置:win7系统用户到C:\Users\[你的用户名]\AppData\Roaming\Macromedia\FlashPlayer\#SharedObjects\XP或2003用户到:C:\DocumentsandSettings\用户名\ApplicationData\Macromedia\FlashPlayer\#SharedObjects\ ---------------------作者:iteye_
安装谷歌浏览器之后经常遇到Flash崩溃或者浏览器在浏览Flash内容时卡死的情况。在网上查找资料大多都认为应该是浏览器自带的Flash插件工作模式引起的问题,解决方法如下:首先在地址栏输入chrome://plugins/显示浏览器使用的插件。点击右上角的详细信息,可以看到Flash插件为进程外
之前一直使用的W25Q16spiflash都没问题,换了一款W25Q80后发现工作不正常,经过测试,初步定位到问题在于初始化SPI后是否将CS拉高。于是又去查看了一下原厂代码:发现原厂的代码初始化SPI接口时是专门拉高CS的。结论:网上很多代码初始化SPI接口时没有专门拉高CS,对某些型号可能确实
======================================================NANDFlash最小存储单元:写数据操作:通过对控制闸(ControlGate)施加高电压,然后允许源极(SOURCE)和汲极(RRAIN)间的N信道(N-Channel)流入电子,等到电流够强,电子获得足够能量时,便会越过浮置闸(FloatingGate)底下的二氧化硅层(S
安装CnarioPlayer3.8.1.156或其他版本时,有时会出现如下提示:Warning4154.AdobeFlashPlayer13...notcorrectlyinstalled:请前往AdobeFlash网站,并选择下图示的版本下载安装: