1. 安装jre,其实不需要jdk
下载
jre-6u30-windows-x64.exe
2. 设置环境变量
参照 http://blog.csdn.net/liling422/article/details/6583282
JAVA_HOME指明JDK安装路径,就是刚才安装时所选择的路径(假设安装在D:\Program Files\Java\jdk1.6.0_10),此路径下包括lib,bin,jre等文件夹(此变量最好设置,因为以后运行tomcat,Eclipse等都需要依靠此变量)。
Path使得系统可以在任何路径下识别java命令,设为:%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin
CLASSPATH为java加载类(class or lib)路径,只有类在classpath中,java命令才能识别,设为:.;%JAVA_HOME%\lib;%JAVA_HOME%\lib\tools.jar (要加.表示当前路径)
特别注意:
◆环境变量值的结尾没有任何符号,不同值之间用;隔开(unix中用:)。
◆CLASSPATH变量值中的.表示当前目录。
到此就配置完成了,可以打开cmd然后输入命令:java -version来查看一下JDK的版本信息
如果正确输出了信息就证明配置成功了!~
3,下载 jsdoc_toolkit-2.4.04. 新建一个run.bat文件,内容为
java -jar jsrun.jar app/run.js -a -t=templates/jsdoc todocjs/*.js
新建一个文件夹为todocjs
将js拷贝在todocjs下即可。
5. 运行run.bat
6. 注释如下:
* @fileoverview 包含CWindow类
* @author 胥海燕
* @version 1.0
*/
/**
* @namespace DiliGISApi,DiliGIS编程接口的命名空间
*/
var DiliGISApi = DiliGISApi ? DiliGISApi : {};
/**
* @class 用于绘制、编辑、修改Graphic
*/
DiliGISApi.DrawGraphic = function(graphicLayer) {
///<summary>用于交互画地图对象/summary>
//var _this = this;
var layer = graphicLayer;
/**
* 回调函数的参数为Graphic,包含DiliGISApi.Point,不删除点对象
* popupContent为popup的内容,内容中自动添加一个id=txt_id_geometry的隐藏的input,value为graphic.Geometry.GeoString,如:"[120.2,119]"
*/
this.DrawPoint = function(callback, popupContent) {
///<summary>画点</summary>
try {
var drawPointCtrol = new OpenLayers.Control.DrawFeature(layer, OpenLayers.Handler.Point);
drawPointCtrol.featureAdded = function(feature) {
try {
if (feature != null) {
var graphic = new DiliGISApi.Graphic();
graphic.SetValueByFeature(feature);
if (typeof callback != 'undefined') {
callback(graphic);
}
//创建popup
if (typeof popupContent != 'undefined') {//添加popup
popupContent += "<input id = \"txt_id_geometry\" type = \"hidden\" value =\"" + graphic.Geometry.GeoString + "\" />";
var lonlat = new OpenLayers.LonLat(graphic.Geometry.CenterXY[0], graphic.Geometry.CenterXY[1]);
var popup = new OpenLayers.Popup.FramedCloud("carInfoPopup", lonlat, null,
popupContent,
null, true,
onPopupClose);
popup.setOpacity(0.7);
layer.map.addPopup(popup);
}
} else {
alert("feature is null");
}
drawPointCtrol.deactivate();
layer.map.removeControl(drawPointCtrol);
} catch (e) {
alert("drawPointCtrol->:" + e.name + "," + e.message);
}
}
layer.map.addControl(drawPointCtrol);
drawPointCtrol.activate();
} catch (e) {
alert("DrawPoint->:" + e.name + "," + e.message);
}
};
/**
* 回调函数的参数为点对象:DiliGISApi.Point,函数会自动删除点对象
*/
this.DrawPoint2 = function(callback) {
///<summary>画点</summary>
try {
var drawPointCtrol = new OpenLayers.Control.DrawFeature(layer, OpenLayers.Handler.Point);
drawPointCtrol.featureAdded = function(feature) {
try {
feature.layer.eraseFeatures([feature]);
if (typeof callback != 'undefined') {
var point = new DiliGISApi.Point(feature.geometry.x, feature.geometry.y);
callback(point);
}
drawPointCtrol.deactivate();
layer.map.removeControl(drawPointCtrol);
} catch (e) {
alert("drawPointCtrol->:" + e.name + "," + e.message);
}
}
layer.map.addControl(drawPointCtrol);
drawPointCtrol.activate();
} catch (e) {
alert("DrawPoint->:" + e.name + "," + e.message);
}
};
/**
* 回调函数的参数为线对象:Graphic,包含DiliGISApi.Line,不删除线对象
* popupContent为popup的内容,内容中自动添加一个id=txt_id_geometry的隐藏的input,
* value为graphic.Geometry.GeoString,如:"[[120.2,119],[123.4,54.4]]"
*/
this.DrawLine = function(callback, popupContent) {
try {
var drawLineCtrol = new OpenLayers.Control.DrawFeature(layer, OpenLayers.Handler.Path);
drawLineCtrol.featureAdded = function(feature) {
try {
if (feature != null) {
var graphic = new DiliGISApi.Graphic();
graphic.SetValueByFeature(feature);
if (typeof callback != 'undefined') {
callback(graphic);
}
//创建popup
if (typeof popupContent != 'undefined') {//添加popup
popupContent += "<input id = \"txt_id_geometry\" type = \"hidden\" value =\"" + graphic.Geometry.GeoString + "\" />";
var lonlat = new OpenLayers.LonLat(graphic.Geometry.CenterXY[0], graphic.Geometry.CenterXY[1]);
var popup = new OpenLayers.Popup.FramedCloud("carInfoPopup", lonlat, null,
popupContent,
null, true,
onPopupClose);
popup.setOpacity(0.7);
layer.map.addPopup(popup);
}
} else {
alert("feature is null");
}
drawLineCtrol.deactivate();
layer.map.removeControl(drawLineCtrol);
} catch (e) {
alert("drawLineCtrol->:" + e.name + "," + e.message);
}
}
layer.map.addControl(drawLineCtrol);
drawLineCtrol.activate();
} catch (e) {
alert("DrawLine->:" + e.name + "," + e.message);
}
};
/**
* 回调函数的参数为线对象:DiliGISApi.PolyLine,函数会自动删除线对象
*/
this.DrawLine2 = function(callback) {
try {
var drawLineCtrol = new OpenLayers.Control.DrawFeature(layer, OpenLayers.Handler.Path);
drawLineCtrol.featureAdded = function(feature) {
try {
feature.layer.eraseFeatures([feature]);
if (typeof callback != 'undefined') {
var pts = feature.geometry.components;
var points = [];
var pointCount = pts.length;
for (var i = 0; i <= pointCount - 1; i++) {
points.push([pts[i].x, pts[i].y]);
}
var polyline = new DiliGISApi.PolyLine(points);
callback(polyline);
}
drawLineCtrol.deactivate();
layer.map.removeControl(drawLineCtrol);
} catch (e) {
alert("drawLineCtrol->:" + e.name + "," + e.message);
}
}
layer.map.addControl(drawLineCtrol);
drawLineCtrol.activate();
} catch (e) {
alert("DrawLine->:" + e.name + "," + e.message);
}
};
/**
* 回调函数的参数为面对象:Graphic,包含DiliGISApi.Polygon,不删除面对象
* popupContent为popup的内容,内容中自动添加一个id=txt_id_geometry的隐藏的input,
* value为graphic.Geometry.GeoString,如:"[[120.2,119],[123.4,54.4],[22.3,454.23],[120.2,119]]"
*/
this.DrawPolygon = function(callback, popupContent) {
try {
var drawPolygonCtrol = new OpenLayers.Control.DrawFeature(layer, OpenLayers.Handler.Polygon);
drawPolygonCtrol.featureAdded = function(feature) {
try {
if (feature != null) {
var graphic = new DiliGISApi.Graphic();
graphic.SetValueByFeature(feature);
if (typeof callback != 'undefined') {
callback(graphic);
}
//创建popup
if (typeof popupContent != 'undefined') {//添加popup
popupContent += "<input id = \"txt_id_geometry\" type = \"hidden\" value =\"" + graphic.Geometry.GeoString + "\" />";
var lonlat = new OpenLayers.LonLat(graphic.Geometry.CenterXY[0], graphic.Geometry.CenterXY[1]);
var popup = new OpenLayers.Popup.FramedCloud("carInfoPopup", lonlat, null,
popupContent,
null, true,
onPopupClose);
popup.setOpacity(0.7);
layer.map.addPopup(popup);
}
} else {
alert("feature is null");
}
drawPolygonCtrol.deactivate();
layer.map.removeControl(drawPolygonCtrol);
} catch (e) {
alert("drawPolygonCtrol->:" + e.name + "," + e.message);
}
}
layer.map.addControl(drawPolygonCtrol);
drawPolygonCtrol.activate();
} catch (e) {
alert("DrawPolygon->:" + e.name + "," + e.message);
}
};
/**
* 回调函数的参数为面对象:DiliGISApi.Polygon,函数会自动删除面对象
*/
this.DrawPolygon2 = function(callback) {
try {
var drawPolygonCtrol = new OpenLayers.Control.DrawFeature(layer, OpenLayers.Handler.Polygon);
drawPolygonCtrol.featureAdded = function(feature) {
try {
feature.layer.eraseFeatures([feature]);
if (typeof callback != 'undefined') {
var pts = feature.geometry.components[0].components;
var points = [];
var pointCount = pts.length;
for (var i = 0; i <= pointCount - 1; i++) {
points.push([pts[i].x, pts[i].y]);
}
var polygon = new DiliGISApi.Polygon(points);
callback(polygon);
}
drawPolygonCtrol.deactivate();
layer.map.removeControl(drawPolygonCtrol);
} catch (e) {
alert("drawPolygonCtrol->:" + e.name + "," + e.message);
}
}
layer.map.addControl(drawPolygonCtrol);
drawPolygonCtrol.activate();
} catch (e) {
alert("DrawPolygon->:" + e.name + "," + e.message);
}
};
/**
* 修改单个对象,回调函数的参数为graphic对象
*/
this.Modify = function(callback) {
try {
var modifyCtrol = new OpenLayers.Control.ModifyFeature(layer);
modifyCtrol.onModificationEnd = function(feature) {
try {
if (typeof feature != 'undefined' && feature != null) {
if (typeof callback != 'undefined') {
var graphic = new DiliGISApi.Graphic();
graphic.SetValueByFeature(feature);
callback(graphic);
}
}
modifyCtrol.deactivate();
layer.map.removeControl(modifyCtrol);
} catch (e) {
alert("modifyCtrol->:" + e.name + "," + e.message);
}
}
layer.map.addControl(modifyCtrol);
modifyCtrol.activate();
} catch (e) {
alert("Modify->:" + e.name + "," + e.message);
}
};
/**
* 选择单个对象,回调函数的参数为graphic对象
*/
this.SingleSelect = function(callback) {
try {
var selectCtrol = new OpenLayers.Control.SelectFeature(layer, {
clickout: true, toggle: false,
multiple: false, hover: false,
box: false
});
selectCtrol.onSelect = function(feature) {
try {
if (typeof feature != 'undefined' && feature != null) {
if (typeof callback != 'undefined') {
var graphic = new DiliGISApi.Graphic();
graphic.SetValueByFeature(feature);
callback(graphic);
}
}
selectCtrol.deactivate();
layer.map.removeControl(selectCtrol);
} catch (e) {
alert("selectCtrol->:" + e.name + "," + e.message);
}
}
layer.map.addControl(selectCtrol);
selectCtrol.activate();
} catch (e) {
alert("SingleSelect->:" + e.name + "," + e.message);
}
};
/**
* 选择单并删除个对象,回调函数的参数为graphic对象
*/
this.SingleDelete = function(callback) {
try {
var deleteCtrol = new OpenLayers.Control.SelectFeature(layer, {
clickout: true, toggle: false,
multiple: false, hover: false,
box: false
});
deleteCtrol.onSelect = function(feature) {
try {
var graphic = null;
if (typeof feature != 'undefined' && feature != null) {
graphic = new DiliGISApi.Graphic();
graphic.SetValueByFeature(feature);
}
//删除对象
if (feature.fid == undefined) {
feature.layer.destroyFeatures([feature]);
} else {
feature.state = OpenLayers.State.DELETE;
feature.layer.events.triggerEvent("afterfeaturemodified",
{ feature: feature });
feature.renderIntent = "select";
feature.layer.drawFeature(feature);
}
if (graphic != null && typeof callback != 'undefined') {
callback(graphic);
}
deleteCtrol.deactivate();
layer.map.removeControl(deleteCtrol);
} catch (e) {
alert("selectCtrol->:" + e.name + "," + e.message);
}
}
layer.map.addControl(deleteCtrol);
deleteCtrol.activate();
} catch (e) {
alert("SingleDelete->:" + e.name + "," + e.message);
}
};
/**
* 选择单并删除个对象,使用自定义扩展控件,回调函数的参数为graphic对象,该对象只有Attibute属性可用
*/
this.SingleDelete2 = function(callback) {
try {
var delCtrol = new DeleteFeature(layer);
delCtrol.onDelete = function(feature, f2) {
try {
if (typeof feature != 'undefined' && feature != null) {
if (typeof callback != 'undefined') {
var graphic = new DiliGISApi.Graphic();
graphic.SetValueByFeature(feature);
callback(graphic);
}
}
delCtrol.deactivate();
layer.map.removeControl(delCtrol);
} catch (e) {
alert("selectCtrol->:" + e.name + "," + e.message);
}
}
layer.map.addControl(delCtrol);
delCtrol.activate();
} catch (e) {
alert("SingleDelete2->:" + e.name + "," + e.message);
}
};
/**
* 选择多个对象,回调函数的参数为单个graphic对象,函数将自动对每个graphic执行该回调函数
*/
this.MultSelect = function(callback) {
try {
var multSelectCtrol = new OpenLayers.Control.SelectFeature(layer, {
clickout: true, toggle: false,
multiple: true, hover: false,
box: true
});
multSelectCtrol.onSelect = function(feature) {
try {
if (typeof feature != 'undefined' && feature != null) {
if (typeof callback != 'undefined') {
var graphic = new DiliGISApi.Graphic();
graphic.SetValueByFeature(feature);
callback(graphic);
}
}
multSelectCtrol.deactivate();
layer.map.removeControl(multSelectCtrol);
} catch (e) {
alert("multSelectCtrol->:" + e.name + "," + e.message);
}
}
layer.map.addControl(multSelectCtrol);
multSelectCtrol.activate();
} catch (e) {
alert("MultSelect->:" + e.name + "," + e.message);
}
};
/**
* 选择多个对象2,该方法有问题,弃用
*/
this.MultSelect2 = function(callback) {
try {
var multSelectCtrol = new OpenLayers.Control.SelectFeature(layer, {
clickout: true, toggle: true,
multiple: true, hover: false,
box: true
});
var featureselectedevent = function(feature) {
if (this.selectedFeatures.length > 0) {
if (typeof callback != 'undefined') {
var graphics = [];
for (var i = 0; i < this.selectedFeatures.length; i++) {
var graphic = new DiliGISApi.Graphic();
graphic.SetValueByFeature(this.selectedFeatures[i]);
graphics.push(graphic);
}
callback(graphics);
}
}
multSelectCtrol.deactivate();
layer.map.removeControl(multSelectCtrol);
layer.events.un({
'featureselected': featureselectedevent
});
};
layer.events.on({
'featureselected': featureselectedevent
});
layer.map.addControl(multSelectCtrol);
multSelectCtrol.activate();
} catch (e) {
alert("MultSelect->:" + e.name + "," + e.message);
}
};
/**
* 私有,pupup关闭时调用
*/
var onPopupClose = function(evt) {
try {
for (var i = layer.map.popups.length - 1; i >= 0; --i) {
layer.map.removePopup(layer.map.popups[i]);
}
} catch (e) {
alert("onPopupClose->:\n" + e.name + ":" + e.message);
}
};
/**
* 私有,扩展control,实现点选删除
*/
var DeleteFeature = OpenLayers.Class(OpenLayers.Control, {
onDelete: function() { },
scope: null,
initialize: function(layer, options) {
OpenLayers.Control.prototype.initialize.apply(this, [options]);
if (this.scope === null) {
this.scope = this;
}
this.layer = layer;
this.handler = new OpenLayers.Handler.Feature(
this, layer, { click: this.clickFeature }
);
},
clickFeature: function(feature) {
// if feature doesn't have a fid, destroy it
if (feature.fid == undefined) {
this.layer.destroyFeatures([feature]);
} else {
feature.state = OpenLayers.State.DELETE;
this.layer.events.triggerEvent("afterfeaturemodified",
{ feature: feature });
feature.renderIntent = "select";
this.layer.drawFeature(feature);
}
this.onDelete.call(this.scope, feature);
},
setMap: function(map) {
this.handler.setMap(map);
OpenLayers.Control.prototype.setMap.apply(this, arguments);
},
CLASS_NAME: "OpenLayers.Control.DeleteFeature"
});
};