Windows窗体中的静态谷歌地图 [英] Static google maps in windows form

查看:71
本文介绍了Windows窗体中的静态谷歌地图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



希望有人可以帮我这个,

我想用我的应用程序在我的应用程序中显示谷歌地图br />
webbrowser控件,但问题不是

让它显示地图。



我只想要它显示地图不是整个

谷歌地图网页。



我想将文本框连接到城市名称

和addr ..



这就是我尝试过的:



Hi all,

Hopefully anyone can help me with this,
I want to show google maps in my app using a
webbrowser control, but the problem is not
getting it to show the maps.

I only want it to show the maps not the whole
google maps webpage.

I want to hook up text boxes to the city name
and addr..

This is what I've tried:

private void Loadmaps()
       {
           DataTable dt = new DataTable;
           Addr = txtPhyAddLine1.Text;
           City = txtPhyCity.Text;

           try
           {
               for (int i = 0; i < dt.Rows.Count; i++)
               {
               StringBuilder OpenUpdate = new StringBuilder();
               OpenUpdate.Append("http://maps.googleapis.com/maps/api/staticmap?center=Berkeley,CA&zoom=14&size=400x400&sensor=false");

               mapbrowser.Navigate(OpenUpdate.ToString());
               }
           }

           catch (Exception ex)
           {
               MessageBox.Show(ex.Message.ToString(), "Unable To Load Web Browser");
           }
       }





如果有任何帮助可以获得批准!!



PLEASE ANY HELP WOULD BE APPRICIATED!!

推荐答案

查看 GMap.NET [ ^ ]


你做错了。你所做的是, stringbuilder 在for循环中每次增加一遍又一遍地添加相同的文本。我已经为你修复了代码。 注意:不需要使用 stringbuilder

You are doing it wrong. What you have done is, the stringbuilder is appending the same text over and over again with each increment in for loop. I have fixed the code for you. Note: use of stringbuilder is not required.
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
    if (e.KeyChar == (Char)Keys.Enter)
    {
      City = txtPhyCity.Text;
      string openupdate = "http://maps.googleapis.com/maps/api/staticmap?center="+City+"&zoom=14&size=400x400&sensor=false";

      mapbrowser.Navigate(OpenUpdate);
    }
}


HI


试试这段代码,这个一个适合我......



HI
Try this code, this one works for me......

StringBuilder queryAddress = new StringBuilder();

queryAddress.Append("http://maps.googleapis.com/maps/api/staticmap?center="+City+"&zoom=14&size=400x400&sensor=false");

webBrowser1.Navigate(queryAddress.ToString());


这篇关于Windows窗体中的静态谷歌地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆