Esempio n. 1
0
        private void gMap_OnMapTypeChanged(GMapProvider type)
        {
            //GeocodingProvider
            Geo = gMap.MapProvider as GeocodingProvider;

            updatePositions();
        }
Esempio n. 2
0
        private void btnPesquisarEndereco_Click(object sender, EventArgs e)
        {
            string             address = tbxEndereço.Text;
            GeoCoderStatusCode status;

            GeocodingProvider geocode = MainMap.MapProvider as GeocodingProvider;

            if (geocode == null)
            {
                MessageBox.Show("O tipo de mapa escolhido não possui \n serviço de geocoding !!!");
                return;
            }

            PointLatLng?point = geocode.GetPoint(address, out status);

            //PointLatLng? point = GMapProviders.GoogleMap.GetPoint(address, out status);



            if (status == GeoCoderStatusCode.G_GEO_SUCCESS && point != null)
            {
                //MessageBox.Show(point.ToString());
                MainMap.Position = point.Value;
                MainMap.Zoom     = 18;
            }
        }
Esempio n. 3
0
        private void Form1_Load_1(object sender, EventArgs e)
        {
            this.gMapControl1.BackColor = Color.Red;
            //设置控件的管理模式
            this.gMapControl1.Manager.Mode = AccessMode.ServerAndCache;
            //设置控件显示的地图来源
            this.gMapControl1.MapProvider = GMapProviders.GoogleChinaMap;
            //设置控件显示的当前中心位置

            gp = GMapProviders.OpenStreetMap as GeocodingProvider;

            //31.7543, 121.6281
            this.gMapControl1.Position = new PointLatLng(28.210422, 112.976478);
            //设置控件最大的缩放比例
            this.gMapControl1.MaxZoom = 18;
            //设置控件最小的缩放比例
            this.gMapControl1.MinZoom = 1;
            //设置控件当前的缩放比例
            this.gMapControl1.Zoom = 11;
            //创建一个新图层
            routes            = new GMapOverlay("routes");
            MyMark            = new GMapOverlay("MyMark");
            routes.IsVisibile = true;               //可以显示
            MyMark.IsVisibile = true;
            this.gMapControl1.Overlays.Add(routes); //添加到图层列表中
            this.gMapControl1.Overlays.Add(MyMark);
            //创建一个图标
            GMapMarker gMapMarker = new GMarkerGoogle(gMapControl1.Position, GMarkerGoogleType.arrow);

            //添加图层routes中
            gMapMarker.ToolTipText = "我的商店";
            this.MyMark.Markers.Add(gMapMarker);
            // this.gMapControl1.Dock = DockStyle.Fill;//将控件全屏显示
            gMapControl1.Overlays.Add(polygons);
        }
Esempio n. 4
0
        private void btnEndLatLon_Click(object sender, EventArgs e)
        {
            List <Placemark> plc = null;

            string endereco = "";

            GeocodingProvider geocode = MainMap.MapProvider as GeocodingProvider;

            if (geocode == null)
            {
                MessageBox.Show("O tipo de mapa escolhido não possui \n serviço de geocoding !!!");
                return;
            }


            /*GeoCoderStatusCode st = geocode.GetPlacemarks(MainMap.Position, out plc);
             * //GeoCoderStatusCode st = GMapProviders.GoogleMap.GetPlacemarks(MainMap.Position, out plc);
             *
             * if (st == GeoCoderStatusCode.G_GEO_SUCCESS && plc != null)
             * {
             *  foreach (var pl in plc)
             *  {
             *      if (!string.IsNullOrEmpty(pl.PostalCodeNumber))
             *      {
             *          endereco += "Acurácia: " + pl.Accuracy + ", | Endereço: " + pl.Address + " | CEP: " + pl.PostalCodeNumber + "\n";
             *      }
             *  }
             *
             *  MessageBox.Show(endereco);
             * }*/


            GeoCoderStatusCode st;
            Placemark?         place = geocode.GetPlacemark(MainMap.Position, out st);

            if (st != GeoCoderStatusCode.G_GEO_SUCCESS || place == null)
            {
                MessageBox.Show("Não foi possivel retornar o endereço da localização!");
                return;
            }

            endereco += "Acurácia: " + place.Value.Accuracy + ", | Endereço: " + place.Value.Address + " | CEP: " + place.Value.PostalCodeNumber + "\n";
            endereco += "\nAdministrativeAreaName: " + place.Value.AdministrativeAreaName;
            endereco += "\nCountryName: " + place.Value.CountryName;
            endereco += "\nCountryNameCode: " + place.Value.CountryNameCode;
            endereco += "\nDistrictName: " + place.Value.DistrictName;
            endereco += "\nHouseNo: " + place.Value.HouseNo;
            endereco += "\nLocalityName: " + place.Value.LocalityName;
            endereco += "\nNeighborhood: " + place.Value.Neighborhood;
            endereco += "\nPostalCodeNumber: " + place.Value.PostalCodeNumber;
            endereco += "\nStreetNumber: " + place.Value.StreetNumber;
            endereco += "\nSubAdministrativeAreaName: " + place.Value.SubAdministrativeAreaName;
            endereco += "\nSubAdministrativeAreaName: " + place.Value.ThoroughfareName;
            MessageBox.Show(endereco);
        }
Esempio n. 5
0
        public static PointLatLng GetPositionByKeywords(string keys)
        {
            GeoCoderStatusCode status;
            GeocodingProvider  geocodingProvider = GMapProviders.GoogleMap;

            if (geocodingProvider != null)
            {
                PointLatLng?point = geocodingProvider.GetPoint(keys, out status);
                if (status == GeoCoderStatusCode.G_GEO_SUCCESS && point.HasValue)
                {
                    return(point.Value);
                }
            }
            return(new PointLatLng());
        }
Esempio n. 6
0
File: Form1.cs Progetto: mikhp/Agmap
        private void Form1_Load_1(object sender, EventArgs e)
        {


            
            this.gMapControl1.BackColor = Color.Red;
            //设置控件的管理模式
            this.gMapControl1.Manager.Mode = AccessMode.ServerAndCache;
            //设置控件显示的地图来源
            this.gMapControl1.MapProvider = GMapProviders.GoogleChinaMap;
            //设置控件显示的当前中心位置

            gp = GMapProviders.OpenStreetMap as GeocodingProvider;

            //31.7543, 121.6281
            this.gMapControl1.Position = new PointLatLng(28.210422, 112.976478);
            //设置控件最大的缩放比例
            this.gMapControl1.MaxZoom = 18;
            //设置控件最小的缩放比例
            this.gMapControl1.MinZoom = 1;
            //设置控件当前的缩放比例
            this.gMapControl1.Zoom = 11;
            //创建一个新图层
            routes = new GMapOverlay("routes");
            MyMark = new GMapOverlay("MyMark");
            routes.IsVisibile = true;//可以显示
            MyMark.IsVisibile = true;
            this.gMapControl1.Overlays.Add(routes);//添加到图层列表中
            this.gMapControl1.Overlays.Add(MyMark);
            //创建一个图标
            GMapMarker gMapMarker = new GMarkerGoogle(gMapControl1.Position, GMarkerGoogleType.arrow);
            //添加图层routes中
            gMapMarker.ToolTipText = "我的商店";
            this.MyMark.Markers.Add(gMapMarker);
            // this.gMapControl1.Dock = DockStyle.Fill;//将控件全屏显示
            gMapControl1.Overlays.Add(polygons);
        }
Esempio n. 7
0
        public MapForm()
        {
            InitializeComponent();

            if (!DesignMode)
            {
                try
                {
                    System.Net.IPHostEntry e = System.Net.Dns.GetHostEntry("ditu.google.cn");
                }
                catch
                {
                    mapControl.Manager.Mode = AccessMode.CacheOnly;
                    MessageBox.Show("No internet connection avaible, going to CacheOnly mode.", "GMap.NET Demo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }

                mapControl.CacheLocation      = Environment.CurrentDirectory + "\\GMapCache\\"; //缓存位置
                mapControl.MapProvider        = GMapProviders.GoogleChinaMap;                   //google china 地图
                mapControl.MinZoom            = 2;                                              //最小比例
                mapControl.MaxZoom            = 24;                                             //最大比例
                mapControl.Zoom               = 10;                                             //当前比例
                mapControl.ShowCenter         = false;                                          //不显示中心十字点
                mapControl.DragButton         = System.Windows.Forms.MouseButtons.Left;         //左键拖拽地图
                mapControl.Position           = new PointLatLng(32.064, 118.704);               //地图中心位置:南京
                mapControl.MouseWheelZoomType = MouseWheelZoomType.MousePositionWithoutCenter;

                mapControl.MouseClick       += new MouseEventHandler(mapControl_MouseClick);
                mapControl.MouseDown        += new MouseEventHandler(mapControl_MouseDown);
                mapControl.MouseUp          += new MouseEventHandler(mapControl_MouseUp);
                mapControl.MouseMove        += new MouseEventHandler(mapControl_MouseMove);
                mapControl.MouseDoubleClick += new MouseEventHandler(mapControl_MouseDoubleClick);

                mapControl.OnMarkerClick += new MarkerClick(mapControl_OnMarkerClick);
                mapControl.OnMarkerEnter += new MarkerEnter(mapControl_OnMarkerEnter);
                mapControl.OnMarkerLeave += new MarkerLeave(mapControl_OnMarkerLeave);

                mapControl.OnPolygonEnter += new PolygonEnter(mapControl_OnPolygonEnter);
                mapControl.OnPolygonLeave += new PolygonLeave(mapControl_OnPolygonLeave);

                mapControl.Overlays.Add(markersOverlay);
                mapControl.Overlays.Add(locations);
                mapControl.Overlays.Add(regionOverlay);
                mapControl.Overlays.Add(polygonsOverlay);

                mapControl.Overlays.Add(historyGeoOverlay);

                gp = mapControl.MapProvider as GeocodingProvider;
                if (gp == null) //地址转换服务,没有就使用OpenStreetMap
                {
                    gp = GMapProviders.OpenStreetMap as GeocodingProvider;
                }
                GMapProvider.Language = LanguageType.ChineseSimplified; //使用的语言,默认是英文

                draw = new Draw(this.mapControl);
                draw.DrawComplete += new EventHandler <DrawEventArgs>(draw_DrawComplete);

                drawDistance = new DrawDistance(this.mapControl);
                drawDistance.DrawComplete += new EventHandler <DrawDistanceEventArgs>(drawDistance_DrawComplete);
            }

            InitUI();
            InitChinaRegion();
        }