欧美大屁股bbbbxxxx,狼人大香伊蕉国产www亚洲,男ji大巴进入女人的视频小说,男人把ji大巴放进女人免费视频,免费情侣作爱视频

歡迎來到入門教程網(wǎng)!

C#教程

當(dāng)前位置:主頁 > 軟件編程 > C#教程 >

Windows下C#的GUI窗口程序中實(shí)現(xiàn)調(diào)用Google Map的實(shí)例

來源:本站原創(chuàng)|時間:2020-01-10|欄目:C#教程|點(diǎn)擊: 次

對谷歌地圖操作使用的是WebBrowser控件,通過對javascript的操作來實(shí)現(xiàn)對谷歌地圖的各種操作,所以首先要創(chuàng)建一個html文件,并賦給WebBrowser的URl:

<!DOCTYPE html> 
<html> 
  <head> 
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> 
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> 
    <title>Google Maps</title> 
    <link  rel="stylesheet" type="text/css" /> 
    <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> 
    <script type="text/javascript"> 
     
    var map; 
 
    function initialize() {//初始化 
      var myLatlng = new google.maps.LatLng( 34.259442,108.947071); 
      var myOptions = { 
        zoom: 10, 
        center: myLatlng, 
        mapTypeId: google.maps.MapTypeId.ROADMAP 
      } 
      map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); 
    } 
 
    function zoomIn(){//放大函數(shù) 
      var zoomLevel = map.getZoom(); 
      if(zoomLevel < 21){ 
        zoomLevel += 1; 
        map.setZoom(zoomLevel); 
      } 
    } 
 
    function zoomOut(){//縮小函數(shù) 
      var zoomLevel = map.getZoom(); 
      if(zoomLevel > 0){ 
        zoomLevel -= 1; 
        map.setZoom(zoomLevel); 
      } 
    } 
 
    function markLocation(x,y){//標(biāo)記某個位置 
      var myLatlng = new google.maps.LatLng(x, y); 
      map.setCenter(myLatlng);   
      marker = new google.maps.Marker({ 
      map: map, 
      position: myLatlng, 
      draggable:true, 
      title:"緯度:"+x+" 經(jīng)度:"+y 
      }); 
    } 
     
    </script> 
  </head> 
  <body onload="initialize()"> 
   <div id="map_canvas"></div> 
  </body> 
</html> 

 操作地圖的簡單函數(shù)都寫在javascript里
C#源文件如下

using System; 
using System.Collections.Generic; 
using System.ComponentModel; 
using System.Data; 
using System.Drawing; 
using System.Text; 
using System.Windows.Forms; 
 
namespace GoogleMapDemo 
{ 
  public partial class Form1 : Form 
  { 
    public Form1() 
    { 
      InitializeComponent(); 
      string url = Application.StartupPath + "/map-simple.html"; 
      webBrowser1.Url = new Uri(url);//指定url 
    } 
 
    private void toolStripButtonStart_Click(object sender, EventArgs e) 
    { 
      webBrowser1.Document.InvokeScript("initialize");//執(zhí)行jiavascript 
    } 
 
    private void toolStripButtonZoomIn_Click(object sender, EventArgs e) 
    { 
      webBrowser1.Document.InvokeScript("zoomIn"); 
    } 
 
    private void toolStripButtonZoomOut_Click(object sender, EventArgs e) 
    { 
      webBrowser1.Document.InvokeScript("zoomOut"); 
    } 
 
    private void toolStripButtonMark_Click(object sender, EventArgs e) 
    { 
      object[] obj = { toolStripTextBox1.Text, toolStripTextBox2.Text }; 
      webBrowser1.Document.InvokeScript("markLocation", obj); 
    } 
  } 
} 

PS:如果只是想單純地調(diào)用瀏覽器打開網(wǎng)頁,可以這樣:

private void lbllink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)   
    {  
 
      //調(diào)用IE瀏覽器 
      System.Diagnostics.Process.Start("iexplore.exe", "http://www.google.cn");  
 
      //調(diào)用系統(tǒng)默認(rèn)的瀏覽器 
      System.Diagnostics.Process.Start( "http://www.google.cn");  
    }  

private void lbllink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 
    { 
      //調(diào)用IE瀏覽器 
      System.Diagnostics.Process.Start("iexplore.exe", "http://www.google.cn");  
 
      //調(diào)用系統(tǒng)默認(rèn)的瀏覽器 
      System.Diagnostics.Process.Start( "http://www.google.cn");  
    } 

上一篇:Unity UGUI教程之實(shí)現(xiàn)滑頁效果

欄    目:C#教程

下一篇:詳解C#切換窗口

本文標(biāo)題:Windows下C#的GUI窗口程序中實(shí)現(xiàn)調(diào)用Google Map的實(shí)例

本文地址:http://mengdiqiu.com.cn/a1/C_jiaocheng/6589.html

網(wǎng)頁制作CMS教程網(wǎng)絡(luò)編程軟件編程腳本語言數(shù)據(jù)庫服務(wù)器

如果侵犯了您的權(quán)利,請與我們聯(lián)系,我們將在24小時內(nèi)進(jìn)行處理、任何非本站因素導(dǎo)致的法律后果,本站均不負(fù)任何責(zé)任。

聯(lián)系QQ:835971066 | 郵箱:835971066#qq.com(#換成@)

Copyright © 2002-2020 腳本教程網(wǎng) 版權(quán)所有