📄 smismapcontrolie.js
字号:
line.style.zIndex = mapDiv.style.zIndex + 200;
var fill = document.createElement("<v:fill opacity=0.1 color='blue'></v:fill>");
var stroke = document.createElement("<v:stroke dashstyle='solid' color='red'></v:stroke>");
mapDiv.appendChild(line);
line.appendChild(fill);
line.appendChild(stroke);
line.onmousedown = SMISPanOnMouseDown;
line.onmousemove = SMISPanOnMouseMove;
line.onmouseup = SMISOnMouseUp;
line.PointsParam = new SMISPointsParam()
line.origin = map.origin;
line.offset = map.offset;
line.origin.x = map.origin.x;
line.origin.y = map.origin.y;
line.offset.x = map.offset.x;
line.offset.y = map.offset.y;
line.DoPostBack = map.DoPostBack;
line.map = map;
line.lineOffset = new SMISPoint(line.offsetLeft, line.offsetTop);
line.points.value = pointsValue;
}
// var relativePos = SMISGetMouseMapRelativePosition(map);
line.style.left = map.offset.x+"px";
line.style.top = map.offset.y+"px";
SMISClipPolygon(line);
}
function SMISCreateLine(mapId, points)
{
var pointsValue = SMISExtractPoints(points);
var map = SMISGetMap(mapId);
var mapDiv = document.getElementById(mapId);
var editLineId = "SMISEditLine";
var line = document.getElementById(editLineId);
if (!line){
SMISEnableVML();
line = document.createElement("<v:polyline points=\"0,0\"/>");
line.style.position = "absolute";
line.style.visibility = "visible";
line.id = editLineId;
line.style.zIndex = map.parentElement.style.zIndex + 200;
var fill = document.createElement("<v:fill opacity=0.1 color='blue'></v:fill>");
var stroke = document.createElement("<v:stroke dashstyle='solid' color='red' Weight='3' ></v:stroke>");
mapDiv.appendChild(line);
line.appendChild(fill);
line.appendChild(stroke);
line.onmousedown = SMISPanOnMouseDown;
line.onmousemove = SMISPanOnMouseMove;
line.onmouseup = SMISOnMouseUp;
line.PointsParam = new SMISPointsParam()
line.origin = map.origin;
line.offset = map.offset;
line.origin.x = map.origin.x;
line.origin.y = map.origin.y;
line.offset.x = map.offset.x;
line.offset.y = map.offset.y;
line.DoPostBack = map.DoPostBack;
line.map = map;
line.lineOffset = new SMISPoint(line.offsetLeft, line.offsetTop);
line.points.value = pointsValue;
}
line.style.left = map.offset.x+"px";
line.style.top = map.offset.y+"px";
}
//-------------------- end of the second part ----------------------------//
function SMISCreatePoint(mapId, points)
{
SMISCreatePoint_Img(mapId, points);
return;
var pointsValue = SMISExtractPoints(points);
var map = SMISGetMap(mapId);
var mapDiv = document.getElementById(mapId);
var editPointId = "SMISEditPoint";
var circle = document.getElementById(editPointId);
if(!circle){
SMISEnableVML();
circle = document.createElement("<v:oval style='width:12; height:12;' fillcolor='red' />");
circle.style.position = "absolute";
circle.style.visibility = 'visible';
circle.id = editPointId;
circle.style.zIndex = map.parentElement.style.zIndex + 200;
var fill = document.createElement("<v:fill opacity=0.3></v:fill>");
var stroke = document.createElement("<v:stroke dashstyle='solid' Color='blue'></v:stroke>");
mapDiv.appendChild(circle);
// document.body.appendChild(circle);
// circle.appendChild(fill);
// circle.appendChild(stroke);
circle.onmousedown = SMISPanOnMouseDown;
circle.onmousemove = SMISPanOnMouseMove;
circle.onmouseup = SMISOnMouseUp;
circle.PointsParam = new SMISPointsParam()
circle.origin = map.origin;
circle.offset = map.offset;
circle.origin.x = map.origin.x;
circle.origin.y = map.origin.y;
circle.offset.x = map.offset.x;
circle.offset.y = map.offset.y;
circle.DoPostBack = map.DoPostBack;
circle.map = map;
circle.lineOffset = new SMISPoint(circle.offsetLeft, circle.offsetTop);
// circle.points.value = pointsValue;
}
var x = eval(pointsValue.split(",")[0]);
var y = eval(pointsValue.split(",")[1]);
circle.style.left = (map.offset.x = x)+"px";
circle.style.top = (map.offset.y = y)+"px";
}
function SMISCreatePoint_Img(mapId, points)
{
var pointWidth = 30;
var pointHeight = 30;
var pointsValue = SMISExtractPoints(points);
var map = SMISGetMap(mapId);
var mapDiv = document.getElementById(mapId);
var editPointId = "SMISEditPoint";
var circle = document.getElementById(editPointId);
if(!circle){
circle = document.createElement("<img src='images/Edit_Point.gif' width=" + pointWidth + " height=" + pointHeight + "/>");
circle.style.position = "absolute";
circle.style.visibility = 'visible';
circle.id = editPointId;
circle.style.zIndex = map.parentElement.style.zIndex + 200;
mapDiv.appendChild(circle);
circle.onmousedown = SMISPanOnMouseDown;
circle.onmousemove = SMISPanOnMouseMove;
circle.onmouseup = SMISOnMouseUp;
circle.PointsParam = new SMISPointsParam()
circle.origin = new SMISPoint();
// circle.offset = map.offset; // 传的是引用。ft。//
circle.offset = new SMISPoint();
circle.origin.x = map.origin.x;
circle.origin.y = map.origin.y;
circle.offset.x = map.offset.x;
circle.offset.y = map.offset.y;
circle.DoPostBack = map.DoPostBack;
circle.map = map;
circle.lineOffset = new SMISPoint(circle.offsetLeft, circle.offsetTop);
}
var x = eval(pointsValue.split(",")[0]) + eval(map.offset.x) - pointWidth/2; /* 为Edit_Point.gif图片的1/2宽度 */
var y = eval(pointsValue.split(",")[1]) + eval(map.offset.y) - pointHeight/2; /* 为Edit_Point.gif图片的1/2宽度 */
circle.style.left = (circle.offset.x = x)+"px";
circle.style.top = (circle.offset.y = y)+"px";
}
function SMISExtractPoints(points)
{
var pointsValue = "";
if(points){
if( typeof(points) == "object") {
for(var i=0; i<points.length - 1; i++) {
pointsValue += points[i].x + "," + points[i].y + ",";
}
pointsValue += points[i].x + "," + points[i].y;
}
else {
pointsValue = points;
}
}
return pointsValue;
}
function SMISCheckMousePosition(map)
{
var absolutePos = SMISGetMouseAbsolutePosition();
var width, height;
if(map.map){
width = map.map.width;
height = map.map.height;
}
else{
width = map.width;
height = map.height;
}
if ( absolutePos.x <= map.origin.x ||
absolutePos.y <= map.origin.y ||
absolutePos.x >= map.origin.x + width ||
absolutePos.y >= map.origin.y + height ){
return false;
}
else{
return true;
}
}
function IsInAbsOrRelStyle(obj)
{
var objTemp = obj;
while(objTemp){
if(objTemp.style){
var temp = objTemp.style.position.toLowerCase();
if( temp == "absolute" || temp == "relative"){
return true;
}
}
objTemp = objTemp.parentElement;
}
return false;
}
function SMISGetOffsetPosition(element, tagName, pos)
{
var _i = 0, _j = 0;
if(typeof(pos) == "undefined" || pos == null){
pos = new SMISPoint(0, 0);
}
while ( ! (element == null || element.tagName == "BODY" || element.tagName.toLowerCase() == tagName) ){
if(element.style){
var temp = element.style.position.toLowerCase();
if(temp == "absolute" || temp == "relative"){
if(_i > 0) { break; }
else { element = element.offsetParent; continue;}
}
}
_i += 1;
pos.x += eval(element.offsetLeft);
pos.y += eval(element.offsetTop);
var bFlag = typeof(element.style.borderLeftWidth) != "unknown";
if(bFlag && element.style.borderLeftWidth != null && element.style.borderLeftWidth != ""){
pos.x += SMISGetNumFromPixel(element.style.borderLeftWidth);
pos.y += SMISGetNumFromPixel(element.style.borderTopWidth);
}
element = element.offsetParent;
}
return pos;
}
function SMISClipPolygon(polygon, inMoving, offsetX, offsetY)
{
if(!polygon.points) return;
var topY = leftX = 0;
var rightX = polygon.map.width + polygon.map.offset.x;
var bottomY = polygon.map.height + polygon.map.offset.y;
var clipTop, clipRight, clipBottom, clipLeft;
var tempMinX, tempMinY, tempMaxX = rightX, tempMaxY = bottomY;
if(!inMoving || !polygon.minPoint){ // 初始化 //
var pointsArray = polygon.points.value.split(",");
var p;
for(var i = 0; i < pointsArray.length; i++){
p = SMISGetNumFromPixel(pointsArray[i]);
if(i == 0){ tempMinX = tempMaxX = p;}
if(i == 1){ tempMinY = tempMaxY = p;}
if(i%2 == 0){ // x 坐标。 //
if( p < tempMinX){ tempMinX = p;}
}
else{ // y 坐标。 //
if( p < tempMinY){ tempMinY = p;}
}
}
polygon.minPoint = new SMISPoint(tempMinX, tempMinY);
}
else{ // 移动过程中。 //
tempMinX = polygon.minPoint.x + offsetX * 2;
tempMinY = polygon.minPoint.y + offsetY * 2;
}
var tempOffsetX = tempMinX / 2 + polygon.map.offset.x - 2; //polygon.offsetLeft
var tempOffsetY = tempMinY / 2 + polygon.map.offset.y - 2; //polygon.offsetTop
clipTop = tempMinY < 0 ? (topY - tempMinY)*0.5 : 0;
clipRight = (rightX - tempOffsetX);
clipBottom = (bottomY - tempOffsetY);
clipLeft = tempMinX < 0 ? (leftX - tempMinX)*0.5 : 0;
polygon.style.clip = "rect(" + clipTop + "px " + clipRight + "px " + clipBottom + "px " + clipLeft + "px)";
}
/* 在 SmartNavigation 开启的情况下,建议直接在 HTML 页面中使用 <Body ... Onload="functionName"> 的方式进行注册。 */
function SMISAddFuncToWindowEvent(functionName, eventName)
{
var p_szLoad = functionName;
var eventRef = document.body.onload;
if(eventName == "OnResize"){
eventRef = document.body.onresize;
}
// Geneaology :: derived from technique at: http://devshed.com
if(eventRef){
var szLoad = eventRef.toString() ;
var szFunc = p_szLoad.replace("()","");
if(szLoad.indexOf(szFunc) >= 0){ // 已经注册到 onload 中了。
return;
}
var szMergeLoad = ''
+ szLoad.substring( szLoad.indexOf( '{' ) + 1
, szLoad.lastIndexOf( '}' ) )
+ ';\n'
+ p_szLoad + ';\n' ;
eventRef = new Function( szMergeLoad ) ;
}
else{
eventRef = p_szLoad.replace("()","") ;
}
if(eventName == "OnResize"){
document.body.onresize = eval(eventRef);
}
else{
document.body.onload = eventRef;
}
}
/**
* 当页面采用相对定位时,浏览器窗口的缩放会导致 MapControl 的绝对位置发生变化从而导致索引框位置错误。
* 为解决这个问题,建议 body.onresize 事件被触发时调用该函数。 例如:
* 修改页面的 <body> 元素,往其中加入 <body onresize="SMISMapSetPosition('MapControl1')">
* 对 OverviewControl 也要做类似的处理:
* <body onresize="SMISMapSetPosition('MapControl1'); SMISOverviewSetPosition('OverviewControl1')">
**/
function SMISMapSetPosition(mapID)
{
if(mapID == null) { return; }
var mapImageID = mapID + '_MVIMAGE';
var mapLoadingID = mapID + '_divLoading';
var mapQuickPanLeftID = mapID + '_QuickPanDiv_L';
var mapQuickPanRightID = mapID + '_QuickPanDiv_R';
var mapQuickPanUpID = mapID + '_QuickPanDiv_U';
var mapQuickPanDownID = mapID + '_QuickPanDiv_D';
SetMapAbsPosition(mapImageID);
var mapDiv = document.getElementById(mapID);
var map = document.getElementById(mapImageID);
if(mapDiv.style.position != "absolute"){
mapDiv.style.position = "relative";
map.offset = new SMISPoint(0,0);
}
mapDiv = null;
var workLayer = SMISGetWorkLayer(mapID);
if(workLayer){
workLayer.style.left = map.offset.x + "px";
workLayer.style.top = map.offset.y + "px";
}
workLayer = null;
var mapLoading = document.getElementById(mapLoadingID);
if(mapLoading){
mapLoading.style.left = (map.offset.x + (SMISGetNumFromPixel(map.style.width) - SMISGetNumFromPixel(mapLoading.clientWidth))/2)+"px";
mapLoading.style.top = (map.offset.y + (SMISGetNumFromPixel(map.style.height) - SMISGetNumFromPixel(mapLoading.clientHeigth))/2)+"px";
}
mapLoading = null;
var divQuickPan_L = document.getElementById(mapQuickPanLeftID);
var divQuickPan_R = document.getElementById(mapQuickPanRightID);
var divQuickPan_U = document.getElementById(mapQuickPanUpID);
var divQuickPan_D = document.getElementById(mapQuickPanDownID);
if(divQuickPan_L){
divQuickPan_L.style.visibility = 'visible';
divQuickPan_L.style.zIndex = map.style.zIndex + 10;
divQuickPan_L.style.left = map.offset.x+"px";
divQuickPan_L.style.top = (map.offset.y + (SMISGetNumFromPixel(map.style.height))/2 - divQuickPan_L.clientHeight/2)+"px";
}
if(divQuickPan_R){
divQuickPan_R.style.visibility = 'visible';
divQuickPan_R.style.zIndex = map.style.zIndex + 10;
divQuickPan_R.style.left = (map.offset.x + (SMISGetNumFromPixel(map.style.width)) - divQuickPan_R.clientWidth)+"px";
divQuickPan_R.style.top = (map.offset.y + (SMISGetNumFromPixel(map.style.height))/2 - divQuickPan_R.clientHeight/2)+"px";
}
if(divQuickPan_U){
divQuickPan_U.style.visibility = 'visible';
divQuickPan_U.style.zIndex = map.style.zIndex + 10;
divQuickPan_U.style.left = (map.offset.x + (SMISGetNumFromPixel(map.style.width))/2 - divQuickPan_U.clientWidth/2)+"px";
divQuickPan_U.style.top = (map.offset.y)+"px";
}
if(divQuickPan_D){
divQuickPan_D.style.visibility = 'visible';
divQuickPan_D.style.zIndex = map.style.zIndex + 10;
divQuickPan_D.style.left = (map.offset.x + (SMISGetNumFromPixel(map.style.width))/2 - divQuickPan_D.clientWidth/2)+"px";
divQuickPan_D.style.top = (map.offset.y + (SMISGetNumFromPixel(map.style.height)) - divQuickPan_D.clientHeight)+"px";
}
try{
eval( mapID + "_SetDivCustomLayer()" );
}
catch(e){
// alert(show_props(e));
}
map = null;
divQuickPan_L = null;
divQuickPan_R = null;
divQuickPan_U = null;
divQuickPan_D = null;
}
function AddImageCellsToWorkLayer(mapId)
{
// Format: "{'cellLTX':cellLTX, 'cellLTY':cellLTY, 'countX':countX, 'countY':countY, 'cellWidth':cellWidth, 'cellHeight':cellHeight, 'offsetLTX':offsetLTX, 'offsetLTY':offsetLTY,
// 'offsetRBX':offsetRBX, 'offsetRBY':offsetRBY, 'urls':url1|url2|url3|...}"
// or: "url"
var __DEBUG__ = false;
var map = SMISGetMap(mapId);
if(map.ImageCellsAdded){
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -