⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 esri_graphics_vml.js

📁 ARCGIS程序,可以实现查、缩放等功能
💻 JS
字号:
/*
COPYRIGHT 1995-2005 ESRI

TRADE SECRETS: ESRI PROPRIETARY AND CONFIDENTIAL
Unpublished material - all rights reserved under the 
Copyright Laws of the United States.

For additional information, contact:
Environmental Systems Research Institute, Inc.
Attn: Contracts Dept
380 New York Street
Redlands, California, USA 92373

email: contracts@esri.com
*/

function EsriVMLGraphicsElement(id, container) {
  this.inheritsFrom(new EsriGraphicsElement(id));

  this.gc = container.appendChild(document.createElement("div"));
  this.gc.id = this.id + "_gc";
  EsriUtils.setElementStyle(this.gc, "position:absolute; left:0px; top:0px; width:" + ((container.style.width) ? EsriUtils.getStyleValue(container.style.width) + "px" : "100%") + "; height:" + ((container.style.height) ? EsriUtils.getStyleValue(container.style.height) + "px" : "100%") + "; border:0px NONE white; background-color:transparent; overflow:visible;");

  document.body.style.cssText += "zoom:1.0";
  var screenScaleFactor = screen.deviceXDPI / screen.logicalXDPI;
  var elementCount = 0;

  this.clear = function() {
    this.gc.innerHTML = "";
    elementCount = 0;
  }

  this.destroy = function() {
    this.clear();
    if (this.gc.parentNode) this.gc.parentNode.removeChild(this.gc);
  }

  this.clip = function(rect) { EsriUtils.setElementStyle(this.gc, "clip: rect(" + rect.top + "px, " + (rect.left + rect.width) + "px, " + (rect.top + rect.height) + "px, " + rect.left + "px);"); }
  this.clearClip = function() { EsriUtils.setElementStyle(this.gc, "clip:auto;"); }
  this.drawCircle = function(center, radius) { this.drawOval(new EsriRectangle(center.x - radius, center.y - radius, radius * 2, radius * 2)); }
  this.drawLine = function(point1, point2) { this.gc.innerHTML += "<v:line from='" + (point1.x * screenScaleFactor) + "," + (point1.y * screenScaleFactor) + "' to='" + (point2.x * screenScaleFactor) + "," + (point2.y * screenScaleFactor) + "' strokecolor='" + this.lineColor + "'><v:stroke weight='" + this.lineWidth + "px' opacity='" + (this.lineOpacity * 100) + "%' /></v:line>"; }
  this.drawOval = function(bounds) { this.gc.innerHTML += "<v:oval style='position:absolute; width:" + (bounds.width * screenScaleFactor) + "px; height:" + (bounds.height * screenScaleFactor) + "px; top:" + (bounds.top * screenScaleFactor) + "px; left:" + (bounds.left * screenScaleFactor) + "px;' strokecolor='" + this.lineColor + "' fillcolor='" + this.fillColor + "'><v:fill opacity='" + (this.fillOpacity * 100) + "%' /><v:stroke weight='" + this.lineWidth + "px' opacity='" + (this.lineOpacity * 100) + "%' /></v:oval>"; }
  this.drawRectangle = function(rect) { this.gc.innerHTML += "<v:rect style='position:absolute; width:" + (rect.width * screenScaleFactor) + "px; height:" + (rect.height * screenScaleFactor) + "px; top:" + (rect.top * screenScaleFactor) + "px; left:" + (rect.left * screenScaleFactor) + "px;' strokecolor='" + this.lineColor + "' fillcolor='" + this.fillColor + "'><v:fill opacity='" + (this.fillOpacity * 100) + "%' /><v:stroke weight='" + this.lineWidth + "px' opacity='" + (this.lineOpacity * 100) + "%' /></v:rect>"; }
  this.drawImage = function(src, left, top, width, height) { this.gc.innerHTML += "<v:image src='" + src + "' style='position:absolute; left:" + left + "px; top:" + top + "px; width:" + width + "px; height:" + height + "px;'></v:image>"; }

  this.drawPoint = function(point) {
    var size = Math.ceil(this.lineWidth / 2);
    this.drawOval(new EsriRectangle(point.x - size, point.y - size, this.lineWidth, this.lineWidth));
  }

  this.drawPolyline = function(points) {
    var str = "";
    for (var i=0;i<points.length;i++) str += " " + (points[i].x * screenScaleFactor) + " " + (points[i].y * screenScaleFactor);
    this.gc.innerHTML += "<v:polyline points='" + str.trim() + "' strokecolor='" + this.lineColor + "'><v:fill on='false' /><v:stroke weight='" + this.lineWidth + "px' opacity='" + (this.lineOpacity * 100) + "%' /></v:polyline>";
  }

  this.drawPolygon = function(points) {
    var str = "";
    for (var i=0;i<points.length;i++) str += " " + (points[i].x * screenScaleFactor) + " " + (points[i].y * screenScaleFactor);
    str += " " + (points[0].x * screenScaleFactor) + " " + (points[0].y * screenScaleFactor);
    this.gc.innerHTML += "<v:polyline points='" + str.trim() + "' strokecolor='" + this.lineColor + "' fillcolor='" + this.fillColor + "'><v:fill opacity='" + (this.fillOpacity * 100) + "%' /><v:stroke weight='" + this.lineWidth + "px' opacity='" + (this.lineOpacity * 100) + "%' /></v:polyline>";
  }

  this.drawText = function(txt, bounds, fontStyle) {
    txt = txt.replace(/\ /g, "&nbsp;");
    this.gc.innerHTML += "<v:rect style='position:absolute; color:" + this.lineColor + "; border:NONE; left:" + (bounds.left * screenScaleFactor) + "px; top:" + (bounds.top * screenScaleFactor) + "px; width:" + (bounds.width * screenScaleFactor) + "px; height:" + (bounds.height * screenScaleFactor) + "px; overflow:hidden; " + fontStyle + ";'><v:fill opacity='0%' /><v:stroke weight='0px' opacity='0%' /><v:textbox inset='0px, 0px, 0px, 0px'>" + txt + "</v:textbox></v:rect>";
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -