common工具类。
Members
-
staticSuperMap.Util.DEFAULT_PRECISIONnumber
-
为了避免浮点精度错误而保留的有效位数。
- Default Value:
- 14
-
staticSuperMap.Util.isSupportCanvas
-
浏览器是否支持Canvas。
-
staticSuperMap.Util.lastSeqIDnumber
-
不断递增计数变量,用于生成唯一ID。
- Default Value:
- 0
Methods
-
staticSuperMap.Util.applyDefaults(to, from){Object}
common/commontypes/Util.js, line 235 -
Takes an object and copies any properties that don't exist from another properties, by analogy with SuperMap.Util.extend() from Prototype.js.
Name Type Description toObject The destination object.
fromObject The source object. Any properties of this object that are undefined in the to object will be set on the to object.
Returns:
Type Description Object A reference to the to object. Note that the to argument is modified in place and returned by this function. -
staticSuperMap.Util.calculateDpi(viewBounds, viewer, scale, coordUnit, datumAxis){number}
common/commontypes/Util.js, line 739 -
计算iServer服务的REST图层的显示分辨率,需要从iServer的REST图层表述中获取viewBounds、viewer、scale、coordUnit、datumAxis 五个参数,来进行计算。
Name Type Description viewBoundsSuperMap.Bounds 地图的参照可视范围,即地图初始化时默认的地图显示范围。
viewerSuperMap.Size 地图初始化时默认的地图图片的尺寸。
scalenumber 地图初始化时默认的显示比例尺。
coordUnitstring 投影坐标系统的地图单位。
datumAxisnumber 地理坐标系统椭球体长半轴。用户自定义地图的Options时,若未指定该参数的值,则系统默认为WGS84参考系的椭球体长半轴6378137。
Returns:
Type Description number 返回图层显示分辨率。 -
staticSuperMap.Util.cloneObject(obj){Object}
common/commontypes/Util.js, line 962 -
克隆一份Object对象
Name Type Description objObject 需要克隆的对象。
Returns:
Type Description Object 返回对象的拷贝对象,注意是新的对象,不是指向。 -
staticSuperMap.Util.copy(des, soc)
common/commontypes/Util.js, line 61 -
对象拷贝。
Name Type Description desObject 目标对象。
socObject 源对象
-
staticSuperMap.Util.copyAttributes(destination, source)
common/commontypes/Util.js, line 910 -
属性拷贝,不拷贝方法类名(CLASS_NAME)等。
Name Type Description destinationObject 拷贝目标。
sourceObject 源对象。
-
staticSuperMap.Util.copyAttributesWithClip(destination, source, clip)
common/commontypes/Util.js, line 930 -
将源对象上的属性拷贝到目标对象上。(不拷贝 CLASS_NAME 和方法)
Name Type Description destinationObject 目标对象。
sourceObject 源对象。
clipArray.<string> 源对象中禁止拷贝到目标对象的属性,目的是防止目标对象上不可修改的属性被篡改。
-
staticSuperMap.Util.createUniqueID(prefix){string}
common/commontypes/Util.js, line 416 -
创建唯一ID值。
Name Type Description prefixstring 前缀。
Returns:
Type Description string 唯一的ID值。 -
staticSuperMap.Util.extend(destination, source){Object}
common/commontypes/Util.js, line 24 -
复制源对象的所有属性到目标对象上,源对象上的没有定义的属性在目标对象上也不会被设置。
Name Type Description destinationObject 目标对象。
sourceObject 源对象,其属性将被设置到目标对象上。
Returns:
Type Description Object 目标对象。 Example
要复制SuperMap.Size对象的所有属性到自定义对象上,使用方法如下: var size = new SuperMap.Size(100, 100); var obj = {}; SuperMap.Util.extend(obj, size); -
staticSuperMap.Util.getBrowser(){Object}
common/commontypes/Util.js, line 633 -
获取浏览器相关信息。支持的浏览器包括:Opera,Internet Explorer,Safari,Firefox。
Returns:
Type Description Object 获取浏览器名称、版本、设备名称。对应的属性分别为 name, version, device。 -
staticSuperMap.Util.getElement(argument){Array.<HTMLElement>}
common/commontypes/Util.js, line 103 -
获取HTML元素数组。
Name Type Description argumentString | HTMLElement | Window -
Returns:
Type Description Array.<HTMLElement> HTML元素数组。 -
staticSuperMap.Util.getParameters(url){Object}
common/commontypes/Util.js, line 355 -
从URL字符串中解析出参数对象。
Name Type Description urlstring url。
Returns:
Type Description Object 解析出的参数对象。 -
staticSuperMap.Util.getParameterString(params){string}
common/commontypes/Util.js, line 271 -
将参数对象转换为HTTP的GEI请求中的参数字符串。例如:"key1=value1&key2=value2&key3=value3"。
Name Type Description paramsObject 参数对象。
Returns:
Type Description string HTTP的GEI请求中的参数字符串。 -
staticSuperMap.Util.getResolutionFromScale(scale, units){number}
common/commontypes/Util.js, line 547 -
Name Type Description scalenumber 比例尺。
unitsstring 比例尺单位。
Returns:
Type Description number 分辨率。 -
staticSuperMap.Util.getResolutionFromScaleDpi(scale, dpi, coordUnit, datumAxis){number}
common/commontypes/Util.js, line 846 -
根据比例尺和dpi计算屏幕分辨率。
Name Type Description scalenumber 比例尺。
dpinumber 图像分辨率,表示每英寸内的像素个数。
coordUnitstring 投影坐标系统的地图单位。
datumAxisnumber 地理坐标系统椭球体长半轴。用户自定义地图的Options时,若未指定该参数的值,则DPI默认按照WGS84参考系的椭球体长半轴6378137来计算。
Returns:
Type Description number 返回当前比例尺下的屏幕分辨率。 -
staticSuperMap.Util.getScaleFromResolution(resolution, units){number}
common/commontypes/Util.js, line 566 -
分辨率转比例尺。
Name Type Description resolutionnumber 分辨率。
unitsstring 分辨率单位。
Returns:
Type Description number 比例尺。 -
staticSuperMap.Util.getScaleFromResolutionDpi(resolution, dpi, coordUnit, datumAxis){number}
common/commontypes/Util.js, line 874 -
根据resolution、dpi、coordUnit和datumAxis计算比例尺。
Name Type Description resolutionnumber 用于计算比例尺的地图分辨率。
dpinumber 图像分辨率,表示每英寸内的像素个数。
coordUnitstring 投影坐标系统的地图单位。
datumAxisnumber 地理坐标系统椭球体长半轴。用户自定义地图的Options时,若未指定该参数的值,则DPI默认按照WGS84参考系的椭球体长半轴6378137来计算。
Returns:
Type Description number 返回当前屏幕分辨率下的比例尺。 -
staticSuperMap.Util.getTextBounds(style, text, element){Object}
common/commontypes/Util.js, line 1048 -
获取文本外接矩形宽度与高度。
Name Type Description styleSuperMap.Style 文本样式。
textstring 文本内容。
elementObject DOM元素。
Returns:
Type Description Object 返回裁剪后的宽度,高度信息。 -
staticSuperMap.Util.indexOf(array, obj){number}
common/commontypes/Util.js, line 160 -
获取某对象再数组中的索引值。
Name Type Description arrayArray 数组。
objObject 对象。
Returns:
Type Description number 某对象再数组中的索引值。 -
staticSuperMap.Util.isArray(a){boolean}
common/commontypes/Util.js, line 133 -
判断一个对象是否是数组。
Name Type Description aObject 对象。
Returns:
Type Description boolean 是否是数组。 -
staticSuperMap.Util.isElement(o){boolean}
common/commontypes/Util.js, line 124 -
instance of的跨浏览器实现。
Name Type Description oObject 对象。
Returns:
Type Description boolean 是否是页面元素 -
staticSuperMap.Util.isInTheSameDomain(url){boolean}
common/commontypes/Util.js, line 684 -
判断一个 URL 请求是否在当前域中。
Name Type Description urlstring URL 请求字符串。
Returns:
Type Description boolean URL请求是否在当前域中。 -
staticSuperMap.Util.lineIntersection(a1, a2, b1, b2){Object}
common/commontypes/Util.js, line 1003 -
判断两条线段是不是有交点。
Name Type Description a1SuperMap.Geometry.Point 第一条线段的起始节点。
a2SuperMap.Geometry.Point 第一条线段的结束节点。
b1SuperMap.Geometry.Point 第二条线段的起始节点。
b2SuperMap.Geometry.Point 第二条线段的结束节点。
Returns:
Type Description Object 如果相交返回交点,如果不相交返回两条线段的位置关系。 -
staticSuperMap.Util.modifyDOMElement(element, id, px, sz, position, border, overflow, opacity)
common/commontypes/Util.js, line 190 -
修改某DOM元素的许多属性。
Name Type Description elementHTMLElement 待修改的DOM元素。
idstring DOM元素的id。
pxSuperMap.Pixel 包含DOM元素的style属性的left和top属性。
szSuperMap.Size 包含DOM元素的width和height属性。
positionstring DOM元素的position属性。
borderstring DOM元素的style属性的border属性。
overflowstring DOM元素的style属性的overflow属性。
opacitynumber 不透明度值。取值范围为 (0.0 - 1.0)。
-
staticSuperMap.Util.normalizeScale(scale){number}
common/commontypes/Util.js, line 537 -
Name Type Description scalenumber -
Returns:
Type Description number 返回正常的scale值 -
staticSuperMap.Util.rad(x){number}
common/commontypes/Util.js, line 346 -
角度转弧度。
Name Type Description xnumber 角度。
Returns:
Type Description number 弧度。 -
staticSuperMap.Util.removeItem(array, item){Array}
common/commontypes/Util.js, line 144 -
从数组中删除某一项。
Name Type Description arrayArray 数组。
itemObject 数组中要删除的一项。
Returns:
Type Description Array 执行删除操作后的数组。 -
staticSuperMap.Util.reset(obj)
common/commontypes/Util.js, line 77 -
销毁对象,将其属性置空
Name Type Description objObject 目标对象。
-
staticSuperMap.Util.supportCanvas(){boolean}
common/commontypes/Util.js, line 666 -
判断;浏览器是否支持Canvas。
Returns:
Type Description boolean 获取当前浏览器是否支持 HTML5 Canvas 。 -
staticSuperMap.Util.toFloat(number, precision){number}
common/commontypes/Util.js, line 330 -
将字符串以接近的精度转换为数字。
Name Type Description numberstring 字符串。
precisionnumber 精度。
Returns:
Type Description number 数字。 -
staticSuperMap.Util.toJSON(obj){string}
common/commontypes/Util.js, line 771 -
将对象转换成 JSON 字符串。
Name Type Description objObject 要转换成 JSON 的 Object 对象。
Returns:
Type Description string 返回转换后的 JSON 对象。 -
staticSuperMap.Util.transformResult(result){Object}
common/commontypes/Util.js, line 897 -
转换查询结果。
Name Type Description resultObject 查询结果。
Returns:
Type Description Object 转换后的查询结果。 -
staticSuperMap.Util.urlAppend(url, paramStr){string}
common/commontypes/Util.js, line 306 -
给url追加参数。
Name Type Description urlstring 待追加参数的url字符串。
paramStrstring 待追加的参数。
Returns:
Type Description string The new url