请教个【低级】问题,在线等,急!!!!!!!
怎么把这段JAVASCRIPT封装成JS 然后在调用啊1!!!
<script language= "javascript ">
var maps = new LTMaps( "myMap " );
maps.cityNameAndZoom( "beijing " , 10);
maps.handleMouseScroll();
var control2 = new LTStandMapControl();
maps.addControl( control2 );
var points = new Array();
var paintSign = new Array(0);
var strlong = " <%=tempAyr1%> "
var strlat = " <%=tempAyr2%> "
var strsign = " <%=tempAyr3%> ";【调用后台】
var lo ;
var la;
var sign;
lo = strlong.split( ", ");
la = strlat.split( ", ");
sign =strsign.split( ", ");
【·······】
var marker;
for(var n = 0;n <i-1;n++)
{
points.push(new LTPoint(lo[n]*100000,la[n]*100000));//获取坐标
paintSign.push(sign[n]);
marker = new LTMapText(points[n]);//获取标注
addInfoWin(marker,n);
maps.addOverLay(marker);//显示文字
}
var polyLine = new LTPolyLine(points);
maps.addOverLay(polyLine);//添加
polyLine.setLineStroke(2);//宽度
polyLine.setLineColor( "#FF0000 " );//颜色
function addInfoWin(obj , num)
{
obj.setLabel(sign[num]);
}
</script>
[解决办法]
右键工程,添加新项,对话框找到JScript文件,确定,把你的javascript拷贝到对应文件,
保存,
要调用的页面里
<head runat= "server ">
<title> </title>
<script language= "javascript " type= "text/javascript " src= "对应的JScript文件路径 "> </script>
</head>
这样就可以了,调用时直接写方法就行了