`
gstarwd
  • 浏览: 1512233 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

[C#实战]Google Map开发实战参考

    博客分类:
  • .NET
阅读更多

[C# 实战]Google Map开发实战参考 

<script type="text/javascript"> document.body.oncopy = function() { if (window.clipboardData) { setTimeout(function() { var text = clipboardData.getData(&quot;text&quot;); if (text &amp;&amp; text.length &gt; 300) { text = text + &quot;\r\n\n本文来自CSDN博客,转载请标明出处:&quot; + location.href; clipboardData.setData(&quot;text&quot;, text); } }, 100); } } </script><script type="text/javascript"> function StorePage() { d = document; t = d.selection ? (d.selection.type != 'None' ? d.selection.createRange().text : '') : (d.getSelection ? d.getSelection() : ''); void (keyit = window.open('http://www.365key.com/storeit.aspx?t=' + escape(d.title) + '&amp;u=' + escape(d.location.href) + '&amp;c=' + escape(t), 'keyit', 'scrollbars=no,width=475,height=575,left=75,top=20,status=no,resizable=yes')); keyit.focus(); }</script>
using  System;
using  System.Data;
using  System.Configuration;
using  System.Web;
using  System.Web.Security;
using  System.Text;
using  System.Web.UI;
using  System.Web.UI.WebControls;
using  System.Web.UI.WebControls.WebParts;
using  System.Web.UI.HtmlControls;

/**/ ///   <summary>
///  Summary description for GoogleMapCommon
///   </summary>

public   class  GoogleMapCommon
... {
    Page mPageHandel 
=   null ;   
    
string  mMapDivName  =   string .Empty;
    GoogleMapPoint mCenterPoint;
    
string  mMapHandleName;
    
int  mMapZoom;
    
private   readonly   static   string  mGoogleMapURL  =  ConfigurationManager.AppSettings[ " GoogleMapURL " ];
    
/**/ ///   <summary>
    
///  Show Google Map
    
///   </summary>
    
///   <param name="pageHandel"> page handle </param>
    
///   <param name="mapHandleName"> Map Handle Name. </param>
    
///   <param name="mapDivName"> Div where Shows map </param>
    
///   <param name="centerPoint"> center point </param>
    
///   <param name="zoom"> map zoom 1 to 19 </param>

     public  GoogleMapCommon(Page pageHandel,  string  mapHandleName,  string  mapDivName, GoogleMapPoint centerPoint,  int  mapZoom)
    
... {
        mPageHandel 
=  pageHandel;
        mMapHandleName 
=  mapHandleName;
        mMapDivName 
=  mapDivName;
        mCenterPoint 
=  centerPoint;
        
if  (mapZoom  >   19   ||  mapZoom  <   1 )
        
... {
            mMapZoom 
=   4 ;
        }

        
else
        
... {
            mMapZoom 
=  mapZoom;
        }

    }

    
/**/ ///   <summary>
    
///  Show Google mape
    
///   </summary>

     public   void  ShowMap()
    
... {
        ShowMap(
null );
    }

    
/**/ ///   <summary>
    
///   Show Google mape
    
///   </summary>
    
///   <param name="point"></param>

     public   void  ShowMap(GoogleMapPoint point)
    
... {
        GoogleMapPoint[] points 
= ... { point} ;
        ShowMap(points);
    }

    
/**/ ///   <summary>
    
///  Show Google mape
    
///   </summary>
    
///   <param name="points"></param>

     public   void  ShowMap(GoogleMapPoint[] points)
    
... {
        mPageHandel.ClientScript.RegisterClientScriptInclude(
" GoogleMaps " , mGoogleMapURL);
        StringBuilder js 
=   new  StringBuilder( " var  "   +  mMapHandleName  +   "  = null;  " );
        js.AppendLine(
" function load() " );
        js.AppendLine(
" " );
        js.AppendLine(
"      if (GBrowserIsCompatible())  " );
        js.AppendLine(
"      { " );
        js.AppendLine(
"            "   +  mMapHandleName  +   "  = new GMap2(document.getElementById(" "   +  mMapDivName  +   " ")); " );
        js.AppendLine(
"       "   +  mMapHandleName  +   " .setCenter(new GLatLng( "   +  mCenterPoint.Latitude  +   " "   +  mCenterPoint.Longitude  +   " ), "   +  mMapZoom  +   " ); " );
        
if  (points  !=   null )
        
... {
            
for  ( int  i  =   0 ; i  <  points.Length; i ++ )
            
... {
                js.AppendLine(
"  var point "   +  i  +   "  = new GLatLng( "   +  points[i].Latitude  +   " "   +  points[i].Longitude  +   " ) " );
                js.AppendLine(
" var blueIcon = new GIcon(G_DEFAULT_ICON); " );
                js.AppendLine(
" blueIcon.image = "http://www.google.com/intl/en_us/mapfiles/ms/micons/blue-dot.png "; " );
                js.AppendLine(
" blueIcon.iconSize = new GSize(35,35); " );
                js.AppendLine(
" blueIcon.shadowSize=new GSize(60,35); " );
                js.AppendLine(
" markerOptions = { icon:blueIcon };  " ); 
                
if  (points[i].IsBuleIcon)    // Create a blue icon
                 ... {
                    js.AppendLine(
"  var marker "   +  i  +   "  = new GMarker(point "   +  i  +   " ,markerOptions); " );
                }

                
else
                
... {
                    js.AppendLine(
"  var marker "   +  i  +   "  = new GMarker(point "   +  i  +   " ); " );
                }

                
if  ( ! string .IsNullOrEmpty(points[i].PointClickHandle))
                
... {
                    
//  add event
                    js.AppendLine( " GEvent.addListener(marker "   +  i  +   " , "click", function(){  "   +  mMapHandleName  +   " .openInfoWindowHtml(point "   +  i  +   " "   +  points[i].PointClickHandle  +   " )}); " );
                }

                js.AppendLine(mMapHandleName 
+   " .addOverlay(marker "   +  i  +   " ); " );
            }

        }

        js.AppendLine(
"      } " );
        js.AppendLine(
" } " );  // create function finsh
        js.AppendLine( " load(); " );    //  call the load function.
        mPageHandel.ClientScript.RegisterStartupScript(mPageHandel.GetType(),  " Start " , js.ToString(), true );
    }

    
/**/ ///   <summary>
    
///  Google Map Point
    
///   </summary>

     public   struct  GoogleMapPoint
    
... {
        
public  GoogleMapPoint( double  longitude,  double  latitude)
        
... {
            Longitude 
=  longitude;
            Latitude 
=  latitude;
            PointClickHandle 
=   string .Empty;
            IsBuleIcon 
=   false ;
        }

        
public  GoogleMapPoint( double  longitude,  double  latitude,  string  pointClickHandle,  bool  isBuleIcon)
        
... {
            Longitude 
=  longitude;
            Latitude 
=  latitude;
            PointClickHandle 
=  pointClickHandle;
            IsBuleIcon 
=  isBuleIcon;
        }

        
public   double  Longitude;
        
public   double  Latitude;
        
public   string  PointClickHandle;
        
public   bool  IsBuleIcon;
    }

}

  该类封装了Google Maps API的一些最基本功能,供大家参考。 详情请参考: http://code.google.com/apis/maps/documentation/index.html
分享到:
评论

相关推荐

    C# 开发实战教程.pptx

    C# 开发实战教程 C# 开发实战教程 C# 开发实战教程 C# 开发实战教程 C# 开发实战教程 C# 开发实战教程 C# 开发实战教程 C# 开发实战教程 C# 开发实战教程 C# 开发实战教程 C# 开发实战教程 C# 开发实战教程 C# 开发...

    C#开发实战PDF文档

    《C#开发实战》PDF文档是一份详尽的编程学习资料,主要涵盖了C#语言在实际项目中的应用,包括企业电话客服系统、餐饮管理系统以及在线考试系统的开发过程。这些项目代表了C#在不同领域的应用,是理解C#语言特性和...

    C#开发实战1200例.(第Ⅰ卷) pdf

    《C#开发实战1200例(第1卷)》以开发人员在项目开发中经常遇到的问题和必须掌握的技术为中心,介绍了应用C#进行程序开发各个方面的知识和技巧,主要包括C#编程基础、Windows窗体、控件应用、文件操作、C#与Office...

    C#开发实战1200例(第2卷) Part1

    《C#开发实战1200例(第2卷)》非常适合c#项目开发人员、c#初学者及编程爱好者使用,同时也可作为培训机构、大中专院校老师和学生的实践参考用书。 《C#开发实战1200例(第2卷)》以开发人员在项目开发中经常遇到的...

    C#上位机实战开发指南

    下面将从C#和Visual Studio两个角度出发,探讨C#在上位机软件开发中的应用,以及C#语法基础和开发工具的使用。 首先,了解.NET框架的诞生与发展对于掌握C#编程具有重要意义。在.NET框架出现之前,Windows平台的...

    C#开发实战1200例源代码.zip

    《C#开发实战1200例源代码》是一份包含丰富示例的资源集合,专为学习和提升C#编程技能的人士设计。这份压缩包涵盖了C#语言的各个重要方面,通过实际的代码实例,帮助开发者深入理解和掌握C#编程的核心概念和技术。 ...

    C#开发实战1200例第一卷

    《C#开发实战1200例第一卷》是一本专为C#初学者和有一定经验的开发者设计的实战教程,旨在通过丰富的实例帮助读者掌握C#编程技能。书中涵盖的内容广泛,包括C#编程基础、Windows窗体应用、控件的使用以及文件操作等...

    C#开发实战1200例(第Ⅱ卷)光盘

    C#开发实战1200例(第Ⅱ卷) 王小科,王军 清华大学出版社 ... 《C#开发实战1200例(第2卷)》非常适合c#项目开发人员、c#初学者及编程爱好者使用,同时也可作为培训机构、大中专院校老师和学生的实践参考用书。

    C#-googlemap

    本项目"C#-googlemap"显然是一个关于如何在C#应用中使用Google Maps API的实例。下面我们将深入探讨相关的知识点。 首先,要使用Google Maps API,你需要在Google Cloud Platform上注册并获取API密钥。这个过程涉及...

    C#开发实战1200例(第Ⅰ卷) 第一部分.pdf

    C#开发实战1200例(第I卷)是一本专门针对C#编程语言的实际开发案例书籍,适用于不同层次的C#学习者和开发者。本书详细地介绍了C#编程基础、Windows窗体、控件应用、文件操作、C#与Office的高效开发以及图形图像与...

    C#开发实战1200例源码

    C#开发实战1200例(第Ⅰ卷) 这本书籍附带的光盘源码,很有参考价值 二、菜单功能 内附一千多winform开发的教学实例,非常适合初学者用来学习,有兴趣的欢迎下载 三、注意事项 1、开发环境为Visual Studio 2010,...

    C#开发GooGleMap

    在C#中开发Google Map应用是一项常见的任务,它涉及到Web开发、API调用以及地理信息系统(GIS)的应用。Google Maps API允许开发者将地图功能集成到自己的应用程序中,为用户提供交互式的地图视图。以下是关于使用C#...

    C#开发实战1200例(第2卷)源代码_C#_c#编程1200例_

    《C#开发实战1200例(第2卷)源代码》是一部全面涵盖C#编程实践的资源库,旨在帮助开发者深入理解并熟练运用C#语言进行软件开发。这部资料集包含了1200个具体的实例,覆盖了C#语言的各个关键领域,包括基础语法、面向...

    C#开发实战1200例(第Ⅰ卷) 第三部分.pdf

    由于直接提供OCR扫描的文字内容会影响内容的质量和通顺度,我将依据标题、描述和标签提供的信息,结合C#开发领域已知的知识点,来生成一篇关于《C#开发实战1200例(第Ⅰ卷)》的详细介绍文章。 在当今快速发展的编程...

    C#开发实战1200例+第1卷.part7

     《C#开发实战1200例(第1卷)(附光盘)》适合c#的初学者,如高校学生、求职人员作为练习、速查、学习使用,也适合c#程序员参考、查阅。 目录 第1篇 c#编程基础篇 第1章 c#开发环境的使用 第2章 c#语言...

    20个C#项目实战开发及项目源码(全部源码)

    在本资源中,你将获得20个C#项目的实战开发源码,这些项目涵盖了C#编程语言在实际应用中的多种场景,对于学习和提升C#编程技能具有很高的价值。C#是一种由微软开发的面向对象的编程语言,广泛应用于Windows桌面应用...

    C#项目经典实战案例1200例(PDF)

    《C#项目经典实战案例1200例》是一份极具价值的学习资料,它涵盖了C#编程语言在实际开发中的广泛应用。这套资源分为两卷,共计1200个实例,旨在帮助开发者深入理解和掌握C#的核心概念以及在项目开发中的实际应用技巧...

    C#实战项目.pdf

    ### C#实战项目知识点概述 #### 一、窗体与界面设计 在C#实战项目中,窗体与界面设计是非常重要的部分,它不仅决定了应用程序的外观,还直接影响了用户体验。以下是一些关键的知识点: ##### 1.1 菜单应用实例 *...

    C#实战项目_c#实战项目_

    在C#的学习过程中,实战项目是提升技能的关键环节。通过实际操作,你可以深入理解C#语言的特性和应用,同时锻炼解决问题的能力。本项目旨在为你提供一个自我学习和实践的平台,下面将对C#实战项目中的核心知识点进行...

Global site tag (gtag.js) - Google Analytics