📄 toolnetscape.js
字号:
function MapInfoWebRectangleStop(map)
{
if(this.started)
{
map.onmousedown = null;
map.onmousemove = null;
map.onmouseup = null;
this.started = false;
}
}
function MapInfoWebRectangleOnMouseMove(evt)
{
var map = MapInfoWebGetMapInternal(this);
var startPoint = map.PointsData.GetPoint(0);
if(startPoint != null)
{
MapInfoWebUpdateRectangle(map, startPoint, new MapInfoWebPoint(evt.clientX+document.body.scrollLeft, evt.clientY+document.body.scrollTop));
return false;
}
}
function MapInfoWebRectangleOnMouseUp(evt)
{
var map = MapInfoWebGetMapInternal(this);
map.onmousemove = null;
if (this.map != null) this.onmousemove = null;
var theform = document.forms[0];
// Get the current point
map.PointsData.AddPoint(evt.clientX+document.body.scrollLeft, evt.clientY+document.body.scrollTop);
if (map.PointsData.Points.length == 2) {
var fir = map.PointsData.GetPoint(0);
var sec = map.PointsData.GetPoint(1);
var dx = map.PointsData.GetPoint(1).x - map.PointsData.GetPoint(0).x;
var dy = map.PointsData.GetPoint(1).y - map.PointsData.GetPoint(0).y;
if (dx < 0 && dy < 0) {
map.PointsData.Points.length = 0;
map.PointsData.AddPoint(sec.x, sec.y);
map.PointsData.AddPoint(fir.x, fir.y);
} else if (dx < 0 && dy > 0) {
map.PointsData.Points.length = 0;
map.PointsData.AddPoint(sec.x, fir.y);
map.PointsData.AddPoint(fir.x, sec.y);
} else if (dx > 0 && dy < 0) {
map.PointsData.Points.length = 0;
map.PointsData.AddPoint(fir.x, sec.y);
map.PointsData.AddPoint(sec.x, fir.y);
}
}
// Create hidden field for current tool
MapInfoWebCreateHiddenField(theform, map.id + "_CurrentToolName", map.id + "_CurrentToolName", map.MapTools.CurrentTool.Name);
// Create hidden field for points data
map.PointsData.CreatePointsField(map.id);
// Create hidden field that will store selectable layers
MapInfoWebCreateSelectableLayerField(map.parentNode.id);
// Do the postback
map.DoPostBack();
}
//////////////////////////////////////////////////////////////////////////////////////////
// ZoomOutTool, InfoTool methods:
function MapInfoWebPointStart(map)
{
if(!this.started)
{
map.PointsData = new MapInfoWebPointsData();
// Get the absolute map position:
map.origin = MapInfoWebGetAbsolutePosition(map);
map.onmouseup = MapInfoWebToolOnMouseUp;
this.started = true;
}
}
function MapInfoWebPointStop(map)
{
if(this.started)
{
map.onmouseup = null;
this.started = false;
}
}
//////////////////////////////////////////////////////////////////////////////////////////
// PanTool methods:
function MapInfoWebPanStart(map)
{
if(!this.started)
{
map.PointsData = new MapInfoWebPointsData();
// Get the absolute map position:
map.origin = MapInfoWebGetAbsolutePosition(map);
map.onmousedown = MapInfoWebPanOnMouseDown;
map.onmousemove = MapInfoWebPanOnMouseMove;
map.onmouseup = MapInfoWebToolOnMouseUp;
this.started = true;
}
}
function MapInfoWebPanStop(map)
{
if(this.started)
{
map.onmousedown = null;
map.onmousemove = null;
map.onmouseup = null;
this.started = false;
}
}
function MapInfoWebPanOnMouseDown(evt)
{
map = MapInfoWebGetMapInternal(this);
map.parentNode.style.position = 'absolute';
map.PointsData.AddPoint(evt.clientX+document.body.scrollLeft, evt.clientY+document.body.scrollTop);
return false;
}
function MapInfoWebPanOnMouseMove(evt)
{
var map = MapInfoWebGetMapInternal(this);
if ( map.PointsData != null )
{
var startPoint = map.PointsData.GetPoint(0);
if(startPoint != null)
{
MapInfoWebPanImage(map, startPoint, new MapInfoWebPoint(evt.clientX+document.body.scrollLeft, evt.clientY+document.body.scrollTop));
return false;
}
}
}
//////////////////////////////////////////////////////////////////////////////////////////
// RadiusTool methods:
function MapInfoWebCircleStart(map)
{
if (!this.started)
{
// Set up the point data object
map.PointsData = new MapInfoWebPointsData();
// Get the absolute map position:
map.origin = MapInfoWebGetAbsolutePosition(map);
map.onmousedown = MapInfoWebToolOnMouseDown;
map.onmousemove = MapInfoWebCircleOnMouseMove;
map.onmouseup = MapInfoWebCircleOnMouseUp;
this.started = true;
}
}
function MapInfoWebCircleStop(map)
{
if(this.started)
{
map.onmousedown = null;
map.onmousemove = null;
map.onmouseup = null;
this.started = false;
}
}
function MapInfoWebCircleOnMouseMove(evt)
{
var map = MapInfoWebGetMapInternal(this);
var startPoint = map.PointsData.GetPoint(0);
if(startPoint != null)
{
MapInfoWebUpdateCircle(map, startPoint, new MapInfoWebPoint(evt.clientX+document.body.scrollLeft, evt.clientY+document.body.scrollTop));
return false;
}
}
function MapInfoWebCircleOnMouseUp(evt)
{
var theform = document.forms[0];
var map = MapInfoWebGetMapInternal(this);
map.onmousemove = null;
if (this.map != null) this.onmousemove = null;
var endPoint = new MapInfoWebPoint(evt.clientX+document.body.scrollLeft, evt.clientY+document.body.scrollTop);
// Get the current point
map.PointsData.AddPoint(endPoint.x, endPoint.y);
var startPoint = map.PointsData.GetPoint(0);
// The startpoint is the center and radius is the distance
// between the start point and the end point
var radius = Math.sqrt(Math.pow((endPoint.x - startPoint.x), 2) +
Math.pow((endPoint.y - startPoint.y), 2));
// Add radius to pointData object. x value of xy pair will contain radius value. y value will be set to 0;
map.PointsData.AddPoint(radius, -99999);
// Create hidden field for current tool
MapInfoWebCreateHiddenField(theform, map.id + "_CurrentToolName", map.id + "_CurrentToolName", map.MapTools.CurrentTool.Name);
// Create hidden field for points data
map.PointsData.CreatePointsField(map.id);
// Create hidden field that will store selectable layers
MapInfoWebCreateSelectableLayerField(map.parentNode.id);
// Do the postback
map.DoPostBack();
}
//////////////////////////////////////////////////////////////////////////////////////////
// DistanceTool methods:
function MapInfoWebDistanceStart(map)
{
if(!this.started)
{
map.PointsData = new MapInfoWebPointsData();
// Get the absolute map position:
map.origin = MapInfoWebGetAbsolutePosition(map);
map.doPolygon = false;
// Add event handlers to map
map.onmousemove = MapInfoWebPolygonOnMouseMove;
map.onclick = MapInfoWebPolygonOnMouseClick;
map.ondblclick = MapInfoWebPolygonOnDblClick;
this.started = true;
}
}
//////////////////////////////////////////////////////////////////////////////////////////
// PolygonSelectionTool methods:
function MapInfoWebPolygonStart(map)
{
if(!this.started)
{
map.PointsData = new MapInfoWebPointsData();
// Get the absolute map position:
map.origin = MapInfoWebGetAbsolutePosition(map);
map.doPolygon = true;
// Add event handlers to map
map.onmousemove = MapInfoWebPolygonOnMouseMove;
map.onclick = MapInfoWebPolygonOnMouseClick;
map.ondblclick = MapInfoWebPolygonOnDblClick;
this.started = true;
}
}
function MapInfoWebPolygonStop(map)
{
if(this.started)
{
map.onmousemove = null;
map.onclick = null;
map.ondblclick = null;
this.started = false;
}
}
function MapInfoWebPolygonOnMouseClick(evt)
{
var theform = document.forms[0];
var map = MapInfoWebGetMapInternal(this);
// create the vml polyline element
var line = document.getElementById("MapInfoWebEntity");
if(!line)
{
// TODO Should we expose line styles at the tool level???
line = MapInfoWebAddElement("DIV", "RubberPolygon");
line.style.position = "absolute";
line.style.visibility = 'visible';
line.id = "MapInfoWebEntity";
// Set the style to the map parent's z-index:
line.style.zIndex = map.parentNode.style.zIndex + 200;
// Add to the document body:
document.body.appendChild(line);
line.activeTool = map.activeTool;
line.map = map;
// Now set the event handlers for click and dblclick for the div element
line.onclick = MapInfoWebPolygonOnMouseClick;
line.onmousemove = MapInfoWebPolygonOnMouseMove;
line.ondblclick = MapInfoWebPolygonOnDblClick;
line.map = map;
line.style.left = line.left = evt.clientX+document.body.scrollLeft;
line.style.top = line.top = evt.clientX+document.body.scrollLeft;
}
map.PointsData.AddPoint(evt.clientX+document.body.scrollLeft, evt.clientY+document.body.scrollTop);
return false;
}
function MapInfoWebPolygonOnMouseMove(evt)
{
var map = MapInfoWebGetMapInternal(this);
var line = document.getElementById("MapInfoWebEntity");
if(line)
{
MapInfoWebUpdatePolygon(map, new MapInfoWebPoint(evt.clientX+document.body.scrollLeft, evt.clientY+document.body.scrollTop), map.doPolygon);
}
return false;
}
function MapInfoWebPolygonOnDblClick(evt)
{
var map = MapInfoWebGetMapInternal(this);
map.onmousemove = null;
if (this.map != null) this.onmousemove = null;
var theform = document.forms[0];
// Create hidden field for current tool
MapInfoWebCreateHiddenField(theform, map.id + "_CurrentToolName", map.id + "_CurrentToolName", map.MapTools.CurrentTool.Name);
// Create hidden field for points data
map.PointsData.CreatePointsField(map.id);
// Create hidden field that will store selectable layers
MapInfoWebCreateSelectableLayerField(map.parentNode.id);
// Do the postback
map.DoPostBack();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -