Flex端:
protected function application1_preinitializeHandler(event:FlexEvent):void
{
ExternalInterface.addCallback("openRightClick", openRightClick);//注册函数,方便被JS调用
}
private var point:Point=new Point();
protected function map_mouseMoveHandler(event:MouseEvent):void
{
point.x=event.stageX;//屏幕坐标(圆点在屏幕左上角)
point.y=event.stageY-myActive.height; //myActive为map上面的控件的高度
}
public function openRightClick():void
{
arrAs[currentImage-1]._curDir = 8;//当前方向,8为无方向;所以定位时要设置为8表示无方向 ;如果不设置定位不到影像
//map.width,map控件的宽度;map.exetent,控件四个角的地理坐标;
//map原点在左下角,从左到右X坐标变大,从下到上Y坐标变大;screen则原点在左上角,从左到右X坐标变大,从上到下Y坐标变大
coorX = (map.extent.xmax-map.extent.xmin)*point.x/map.width+map.extent.xmin;//屏幕横向为x轴。从左到右坐标变大
coorY = map.extent.ymax-(map.extent.ymax-map.extent.ymin)*point.y/map.height;//屏幕纵向为y轴。从下到上坐标变大
forArrayURL();//循环执行查询,并赋于个img图片地址
}
JS端:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>无标题页</title>
<script language="javascript" type="text/javascript">
var active;
//初始化影像插件
window.onload = function()
{
active = document.getElementById("loadingSWF");
}
document.oncontextmenu = function()// js文档中定义了oncontextmenu右击事件
{
event.returnValue = false; //禁止弹出右键菜单
active.openRightClick();
}
//定位到坐标对应的影像
function findImageByXY()
{
var coorX=document.getElementById("txt_X").value;
var coorY=document.getElementById("txt_Y").value;
active.setXY(coorX,coorY);
}
</script>
</head>
<body style="background-color: #aaa">
<div>
<input id="btnGet" type="button" value="定位到对应坐标的影像" οnclick="findImageByXY()" />
<input id="txt_X" type="text" value="503131.268292774" />
<input id="txt_Y" type="text" value="306360.787042478" />
</div>
<div>
<embed id='loadingSWF' src='trueMap.swf' style='z-index:500; position:absolute;' width='100%' height='100%' bgcolor='#FFFFFF' wmode='transparent' quality='high' allowfullscreen="true"> //如此设置wmode
</embed>
</div>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>无标题页</title>
<script language="javascript" type="text/javascript">
var active;
//初始化影像插件
window.onload = function()
{
active = document.getElementById("loadingSWF");
}
document.oncontextmenu = function()// js文档中定义了oncontextmenu右击事件
{
event.returnValue = false; //禁止弹出右键菜单
active.openRightClick();
}
//定位到坐标对应的影像
function findImageByXY()
{
var coorX=document.getElementById("txt_X").value;
var coorY=document.getElementById("txt_Y").value;
active.setXY(coorX,coorY);
}
</script>
</head>
<body style="background-color: #aaa">
<div>
<input id="btnGet" type="button" value="定位到对应坐标的影像" οnclick="findImageByXY()" />
<input id="txt_X" type="text" value="503131.268292774" />
<input id="txt_Y" type="text" value="306360.787042478" />
</div>
<div>
<embed id='loadingSWF' src='trueMap.swf' style='z-index:500; position:absolute;' width='100%' height='100%' bgcolor='#FFFFFF' wmode='transparent' quality='high' allowfullscreen="true"> //如此设置wmode
</embed>
</div>
</body>
</html>