在B/S框架下,MapXtreme都是基于图片的,也就是说在客户端显示的地图实际上都是一张图片。

地图控件

<cc1:MapControl ID="MapControl1" runat="server" Width="" Height=""/>
在调试模式下,编译后的地图控件
<span id="MapControl1" style="display:inline-block;height:600px;width:800px;"><img width="800px" height="600px" alt=""
src="MapController.ashx?Command=GetMap&amp;Width=800&amp;Height=600&amp;ExportFormat=WindowsPng&amp;Ran=0.00238378299511214"
id="MapControl1_Image" /><script language="javascript" type="text/javascript">
var MapControl1Me = document.getElementById('MapControl1_Image');
MapControl1Me.mapAlias= '';
MapControl1Me.exportFormat= 'WindowsPng';

编译后的地图控件分为三部分:<span><img><script>。通过编译后的控件我们就很清楚接下来该如何进行设置。

<%--地图大小随窗体大小改变--%>
<script type="text/javascript">
//窗体大小发生改变时触发该事件
window.onresize = ChangeMapSize; //设置地图大小
function ChangeMapSize()
{
var winWidth,winHeight;
//获取窗口宽度
if (window.innerWidth)
winWidth = window.innerWidth;
else if ((document.body) && (document.body.clientWidth))
winWidth = document.body.clientWidth;
//获取窗口高度
if (window.innerHeight)
winHeight = window.innerHeight;
else if ((document.body) && (document.body.clientHeight))
winHeight = document.body.clientHeight; //通过深入Document内部对body进行检测,获取窗口大小
if (document.documentElement && document.documentElement.clientHeight && document.documentElement.clientWidth)
{
winHeight = document.documentElement.clientHeight;
winWidth = document.documentElement.clientWidth;
} var mapImage = document.getElementById("MapControl1_Image");
if(mapImage != null)
{
//第一步设置<img>控件的大小
mapImage.width = winWidth;
mapImage.height = winHeight; //第二部设置图片的大小
//对MapXtreme的Web应用稍微有些了解的应该清楚
//客户端实际上是通过下面的浏览器从服务器获取图片的
//以下的相关参数例如width和height是用来设置图片大小的
var url = "MapController.ashx?Command=GetMap" + "&Width=" + winWidth + "&Height=" + winHeight +
"&ExportFormat=" + mapImage.exportFormat + "&includeBorder=false&Ran=" + Math.random();
mapImage.src = url;
} //第三步设置<span>控件大小
var mapControl = document.getElementById("MapControl1");
if(mapControl != null)
{
mapControl.style.width = mapImage.width + 'px';
mapControl.style.height = mapImage.height + 'px';
}
}
</script>

可根据需要考虑是否在添加<body onload="ChangeMapSize();">。

MapXtrem + Asp.net 地图随窗体改变大小的更多相关文章

  1. Qt 无边框窗体改变大小 完美实现(全部自己实现)

    近期,做项目用到无边框窗体,令人蛋疼的是无边框窗体大小的改变要像右边框那样,上下左右四周,而且要流畅. 网上也找了些代码,发现居然还要连接到windows事件,这显然不合常理,后来自己新建了demo, ...

  2. Qt 无边框窗体改变大小 完美实现

    近期,做项目用到无边框窗体,令人蛋疼的是无边框窗体大小的改变要像右边框那样,上下左右四周,而且要流畅. 网上也找了些代码,发现居然还要连接到windows事件,这显然不合常理,后来自己新建了demo, ...

  3. C#控件根据窗体改变大小

    using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using Sy ...

  4. winform无边框窗体更改大小

    实现方式一: const int HTLEFT = 10; const int HTRIGHT = 11; const int HTTOP = 12; const int HTTOPLEFT = 13 ...

  5. C#手动改变自制窗体的大小

    Form1.cs using System;using System.Collections.Generic;using System.ComponentModel;using System.Data ...

  6. C# 无边框窗体移动和改变大小的实现

    自己给软件做的皮肤,将窗体设为无边框后,想要其具有正常窗体的移动和改变大小功能,以下代 码可以实现.... //需添加using System.Runtime.InteropServices; [Dl ...

  7. WPF 窗体中的 Canvas 限定范围拖动 鼠标滚轴改变大小

    xaml代码: <Canvas Name="movBg"> <Canvas.Background> <LinearGradientBrush EndP ...

  8. 黄聪:C#图像处理(各种旋转、改变大小、柔化、锐化、雾化、底片、浮雕、黑白、滤镜效果) (转)

    一.各种旋转.改变大小 注意:先要添加画图相关的using引用. //向右旋转图像90°代码如下:private void Form1_Paint(object sender, System.Wind ...

  9. C# (GDI+相关) 图像处理(各种旋转、改变大小、柔化、锐化、雾化、底片、浮雕、黑白、滤镜效果) (转)

    C#图像处理   (各种旋转.改变大小.柔化.锐化.雾化.底片.浮雕.黑白.滤镜效果)     一.各种旋转.改变大小   注意:先要添加画图相关的using引用.   //向右旋转图像90°代码如下 ...

随机推荐

  1. Java多线程详解

    Java线程:概念与原理 一.操作系统中线程和进程的概念 现在的操作系统是多任务操作系统.多线程是实现多任务的一种方式. 进程是指一个内存中运行的应用程序,每个进程都有自己独立的一块内存空间,一个进程 ...

  2. AngularJS模块的详解

    AngularJS模块的详解 在讲angularjs的模块之前,我们先介绍一下angular的一些知识点: AngularJS是纯客户端技术,完全用Javascript编写的.它使用的是网页开发的常规 ...

  3. Spring之使用Annotation注解开发项目

    我们也可以使用Annotation来实现注入操作,提高我们写代码的灵活性和效率.spring中要使用annotation,需要在配置文件中增加: <beans xmlns="http: ...

  4. C#验证IP地址

    using System.Net; try { IPAddress a = IPAddress.Parse(输入的IP字符串); } catch (System.Exception ex) { Mes ...

  5. CodeSmith 生成代码

    使用CodeSmith 生成代码 CodeSmith是一款优秀的代码生成工具.在ORM中,它能帮助我们生成实体类.XML配置文件,从而简化了我们一部分的开发工作.下面简要说说它的基本用法. 1.  打 ...

  6. OCP-1Z0-051-题目解析-第10题

    10. View the Exhibit and examine the structure of the PROMOTIONS table. Each promotion has a duratio ...

  7. 使用AutoTools自动生成Makefile

    前两天赶时间写了个简易的数据库系统,实现了简单的增删改查等功能.因为赶实验...无节操的我用shell实现的文件读写...咳咳...这都不是重点,重点是自己写Makefile感觉有点不伦不类...虽然 ...

  8. LeetCode之Min Stack

    1.原文问题描述: Design a stack that supports push, pop, top, and retrieving the minimum element in constan ...

  9. iOS UIWebView键盘操控

    +-------------------------+ 假设你有以下的问题,也许这篇文章将帮助你. 键盘遮盖了UIWebView. 怎样拖动UIWebView来移除键盘. 键盘出现时UIWebView ...

  10. 谈一谈struts2和springmvc的拦截器

    最近涉及到了两个项目,都需要考虑全局的拦截器,其功能就是判断session的登陆状态,如果session信息完好,可以从中取得相应的信息,则放行,否则拦截,进入重定向的uri. 既然是全局的拦截器,其 ...