Mapxtreme 中如何自定义选择工具?
使用mapxtreme 2005 + asp.net,开发工程中需要自定义一个圆形选择工具,即在地图上画一个圆,把圆形内的商店全部选择出来,可是如何开发,根本摸不着头绪。参考自带例子中的infotool写了一个但是在圆形划了以后,地图就不显示了。猜测是因为server的命令中没有让地图刷新的命令,但是infotool里面也没有呀,如果是的话应该往哪里加呢?
我的code.
页面文件:
<cc1:RadiusSelectionTool ID="RadiusSelectionTool2" runat="server" MapControlID="MapControl1" ClientCommand="MapCommand" Command="CustRadiusSelectionServerCommand" ActiveImageUrl="MapXtremeWebResources/RadiusSelectionToolControlActive.gif" ClientInteraction="RadInteraction" CursorImageUrl="MapXtremeWebResources/MapInfoWebRadiusSelection.cur" InactiveImageUrl="MapXtremeWebResources/RadiusSelectionToolControlInactive.gif" ResourcesPath="js" />
--------------------编程问答-------------------- CusRadius.js
function CustRadiusCommand(name, interaction)
{
if(arguments.length>0)
{
this.Init(name,interaction);
}
}
CustRadiusCommand.prototype = new MapCommand();
CustRadiusCommand.prototype.constructor = CustRadiusCommand;
CustRadiusCommand.superclass = MapCommand.prototype;
CustRadiusCommand.prototype.Excute = function(){
this.CreateUrl();
var xmlHttp = CreateXMLHttp();
xmlHttp.open("GET",this.url,false);
xmlHttp.send(null);
this.result = xmlHttp.responseText;
this.UpdateMap();
dataDiv = $("#dataDiv");
dataDiv.html("");
dataDiv.html(this.result);
}
CustRadiusSelection.cs 文件
--------------------编程问答-------------------- 新问题,找到怎么可以刷新地图了,要用
[Serializable]
public class CustRadiusSelection : MapBaseCommand
{
public CustRadiusSelection()
{
//
// TODO: Add constructor logic here
//
Name = "CustRadiusSelectionServerCommand";
}
public override void Execute()
{
StateManager sm = StateManager.GetStateManagerFromSession();
if(sm==null)
{
if(StateManager.IsManualState())
{
throw new NullReferenceException("Cannot find instatnce of statemanager is the asp.net Session");
}
}
ParseContext();
if(sm!=null)
{
PrepareStateManagerParamsDictionary易做图;
sm.RestoreState();
}
Process();
}
public override void Process()
{
StringWriter sWriter = new StringWriter(new StringBuilder("test info"));
HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.Write(sWriter.ToString());
}
}
MemoryStream memoryStream = model.GetMap(MapAlias, MapWidth, MapHeight, ExportFormat);
StreamImageToClient(memoryStream);
但是如果加入这句,下面的语句要就必须去掉,这可又怎么办呢?我怎么才能够即使地图刷新,又让上面的 "test info" 显示到页面上呢。
StringWriter sWriter = new StringWriter(new StringBuilder("test info"));
HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.Write(sWriter.ToString());
多谢多谢。
--------------------编程问答-------------------- 终于搞定了,用js发出两个xmlhttp的请求,第二个请求里面加另外一个命令,然后再server的命令里面用request.querystiring, 做一个判断,各做各的事,
譬如,如果querstring是getmap,用streamimageToClient来刷新地图,如果querystring是radiusselction,则输出table!
补充:企业软件 , 地理信息系统