位置信息,其中鼠标点击地图GMap.net [英] Location information where mouse click on the map GMap.net

查看:1388
本文介绍了位置信息,其中鼠标点击地图GMap.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Win Forms应用程序以及GMap.net(使我们能够在Win Forms应用程序中使用Google地图的库)。直到点,我能够得到我的鼠标点击(左键点击)的坐标ie(纬度和经度)。

I'm working on Win Forms application along with GMap.net(a library that enables us to use Google Maps in Win Forms Application). Coming straight to the point, I be able to get the coordinates i.e (Latitude and Longitude) where my mouse click (left click).

 private void gm1_MouseDoubleClick(object sender, MouseEventArgs e)
    {
        if (e.Button == System.Windows.Forms.MouseButtons.Left)
        {
            double lat = gm1.FromLocalToLatLng(e.X, e.Y).Lat;
            double lng = gm1.FromLocalToLatLng(e.X, e.Y).Lng;
        }
    }



我没有找到一种方法来获取

I did not find a way to get the location of that place i.e Country Name, city name etc.

我搜索了Google地图的论坛,但我没有找到此问题的回答。

I've searched the forum of Google maps but i did not find this issue answered.

任何

推荐答案

这将会列出您点击的位置

This will give you a list of the named places on the position you click on the map.

   private void map_MouseClick(object sender, MouseEventArgs e)
    {
        if (e.Button == System.Windows.Forms.MouseButtons.Left)
        {
            double lat = map.FromLocalToLatLng(e.X, e.Y).Lat;
            double lng = map.FromLocalToLatLng(e.X, e.Y).Lng;
        }

        List<Placemark> plc = null;
        var st = GMapProviders.GoogleMap.GetPlacemarks(map.FromLocalToLatLng(e.X, e.Y), out plc);
        if (st == GeoCoderStatusCode.G_GEO_SUCCESS && plc != null)
        {
            foreach (var pl in plc)
            {
                if (!string.IsNullOrEmpty(pl.PostalCodeNumber))
                {
                    Debug.WriteLine("Accuracy: " + pl.Accuracy + ", " + pl.Address + ", PostalCodeNumber: " + pl.PostalCodeNumber);
                }
            }
        }
    }

这篇关于位置信息,其中鼠标点击地图GMap.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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