惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google DeepMind News
Google DeepMind News
博客园_首页
H
Help Net Security
T
Tailwind CSS Blog
S
SegmentFault 最新的问题
GbyAI
GbyAI
Scott Helme
Scott Helme
D
Docker
Hacker News: Ask HN
Hacker News: Ask HN
P
Privacy & Cybersecurity Law Blog
Jina AI
Jina AI
雷峰网
雷峰网
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Spread Privacy
Spread Privacy
G
GRAHAM CLULEY
C
Cisco Blogs
The Hacker News
The Hacker News
F
Full Disclosure
Y
Y Combinator Blog
Blog — PlanetScale
Blog — PlanetScale
Recent Announcements
Recent Announcements
G
Google Developers Blog
量子位
K
Kaspersky official blog
Cisco Talos Blog
Cisco Talos Blog
The Cloudflare Blog
A
About on SuperTechFans
C
Cybersecurity and Infrastructure Security Agency CISA
Last Week in AI
Last Week in AI
博客园 - 三生石上(FineUI控件)
Microsoft Security Blog
Microsoft Security Blog
Martin Fowler
Martin Fowler
T
Tenable Blog
P
Palo Alto Networks Blog
H
Heimdal Security Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
W
WeLiveSecurity
Schneier on Security
Schneier on Security
The Register - Security
The Register - Security
F
Fortinet All Blogs
Stack Overflow Blog
Stack Overflow Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
T
The Blog of Author Tim Ferriss
N
News and Events Feed by Topic
Hugging Face - Blog
Hugging Face - Blog
小众软件
小众软件
V
V2EX
爱范儿
爱范儿

博客园 - protorock

WPF:通过Window.DataContext实现窗口间传值 How to add dependency on a Windows Service AFTER the service is installed 实现泛型IEnumerable接口 关于Local System/Local Service/Network Service账户 vs2010 c# 管理win7防火墙 WIN7系统中连接点(Junction Points) 程序集强名称(Strong Name)延迟签名与签名 VISUAL STUDIO 2010 单元测试 Windows Server 2008 R2上Ext.net 生产环境搭建 在Windows7 (SP1)配置IIS7.5 + .Net Framework 4.0.30319 web.config 加密步骤 - protorock - 博客园 GridView 与自定义对象的绑定和分页 在Windows 2003 中发布 ASP.NET 2.0 + SQL SERVER Express SQL Server 2005 Express Edition 用户实例 在 windows2003 Server VS2005 安装 .Net 3.0 .net framework 2.0,3.0与3.5之间的关系 SharpMap AjaxMapControl 中 Zoomin/Zoomout 操作时冻结问题 Sharpmap AjaxMapControl 分析 HTTP 协议概要(二) 持久连接
将Google Map 与ASP.NET AJAX 扩展集成
protorock · 2008-04-17 · via 博客园 - protorock

1. 问题的提出:
   从所周知,Google map 提供的API有其自身的Ajax实现,如果要将Google Map API 嵌入到Asp.net Ajax 扩展的网页如何实现Google Map API 与Asp.net Ajax 客户端扩展库协调是必须考虑的问题。

2. 本文的目的:
   将Google Map 嵌入到一个Asp.net Ajax Enabled 的网页中,利用Asp.net Ajax客户端扩展库 Sys.Net.WebRequest 对象,从服务器请求XML数据,并将XML数据显示在 Google Map 的 OverLay 上。

3. 实现方法:
   利用Asp.net Ajax客户端扩展库创建一个名为 GoogleMap.Map 对象。并将Google Map初始化已经撤销对象处理封装在这个对象中。

4 .客户端代码:

    <script type="text/javascript">
        
//<![CDATA[
       Type.registerNamespace("GoogleMap");
        GoogleMap.Map 
= function(element) 
        
{
            GoogleMap.Map.initializeBase(
this, [element]);
            
this._mapCanvas = element;
            
this._map = null;
            
this._infoTimeElement = null;
            
this._updateElement = null;
            
this._url = null;
        }

        GoogleMap.Map.prototype 
= {
            initialize : 
function() {
                GoogleMap.Map.callBaseMethod(
this'initialize');
                
                
this._map = new GMap2(this._mapCanvas);
                
this._map.addControl(new GLargeMapControl());
                
this._map.setCenter(new GLatLng(29.47921866121.86541563), 12);
                
this._map.setMapType(G_HYBRID_MAP);
                
                $addHandlers(
this._updateElement, {'click'this.update}this);
            }

            dispose : 
function() {
                $clearHandlers(
this._updateElement);
                GUnload();
                
this._map = null;
                GoogleMap.Map.callBaseMethod(
this'dispose');
            }

            update: 
function() {
                
var webRequest = new Sys.Net.WebRequest();
                webRequest.set_url(
this._url);
                webRequest.add_completed(Function.createCallback(
this.onSuccessedXML, this));
                webRequest.invoke();
            }
,
            onSuccessedXML : 
function(executor, eventArgs, context)
            
{
                context._map.clearOverlays();
                
if(executor.get_responseAvailable()) {
                    
var xml = executor.get_xml();
                    
var markers = xml.documentElement.getElementsByTagName('marker');
                    context._infoTimeElement.innerHTML 
= markers[0].getAttribute('t');
                    
for(var i=1; i<markers.length; i++{
                        
var point = new GLatLng(parseFloat(markers[i].getAttribute('lat')), parseFloat(markers[i].getAttribute('lng')));
                        
var text = new Sys.StringBuilder(markers[i].getAttribute('name'));
                        text.append(
'<br />');
                        text.append( markers[i].getAttribute(
'txt'));
                        text.append(
'<br />');
                        text.append( markers[i].getAttribute(
'txt1'));
                        text.append(
'<br />');
                        text.append( markers[i].getAttribute(
'txt2'));
                        context._map.addOverlay(context.createMarker(point, text.toString()));
                    }

                }

            }
,
            createMarker : 
function(point, text) {
                
var defaultIcon = new GIcon(G_DEFAULT_ICON);
                
var m = new GMarker(point, {icon:defaultIcon});
                GEvent.addListener(m, 
'click'function(){ m.openInfoWindowHtml(text); });
                
return m;
            }
,
            get_infoTimeElement : 
function() {
                
return this._infoTimeElement;
            }
,
            set_infoTimeElement : 
function(value) {
                
this._infoTimeElement = value;
            }
,
            get_updateElement : 
function() {
                
return this._updateElement;
            }
,
            set_updateElement : 
function(value) {
                
this._updateElement = value;
            }
,
            get_url : 
function() {
                
return this._url;
            }
,
            set_url : 
function(value) {
                
this._url = value;
            }

        }

        GoogleMap.Map.registerClass(
'GoogleMap.Map', Sys.UI.Control);
        Sys.Application.add_init(pageInit);
        
function pageInit()
        

            $create(GoogleMap.Map, 
                
'updateElement': $get('refreshInfo'), 'infoTimeElement' : $get('ctl00_Content_pageInfo_LabelInfoTime'),  'url' : 'GMapBus.ashx'},
                
{}
                
{}
                $get(
'pageContent'));
        }
 
        
//]]>          
    </script>