Exemplo n.º 1
0
        private void SetUpMap(Settings p_Settings)
        {
            // Initialize map:
            //use google provider
            gMapControl1.MapProvider = GoogleMapProvider.Instance;
            //get tiles from server only
            gMapControl1.Manager.Mode = AccessMode.ServerOnly;
            //not use proxy
            GMapProvider.WebProxy = null;
            //center map


            string lat    = p_Settings.DefaultLatitude.ToString();
            string longit = p_Settings.DefaultLongitude.ToString();

            lat.Replace(',', '.');
            longit.Replace(',', '.');
            var start = new PointLatLng(Convert.ToDouble(lat), Convert.ToDouble(longit));

            gMapControl1.Position = start;


            //zoom min/max; default both = 2
            gMapControl1.DragButton     = MouseButtons.Left;
            gMapControl1.MarkersEnabled = true;

            gMapControl1.CenterPen = new Pen(Color.Transparent, 2);
            gMapControl1.MinZoom   = trackBar1.Maximum = 1;
            gMapControl1.MaxZoom   = trackBar1.Maximum = 20;
            trackBar1.Value        = 15;

            //set zoom
            gMapControl1.Zoom = trackBar1.Value;

            GMapOverlay userOverlay = new GMapOverlay("user");
            Bitmap      userBitmap  = new Bitmap(12, 12);

            using (Graphics g = Graphics.FromImage(userBitmap))
            {
                using (Brush b = new SolidBrush(Color.Goldenrod))
                {
                    g.FillEllipse(b, 0, 0, 12, 12);
                }
            }


            GMarkerGoogle user = new GMarkerGoogle(start, userBitmap);

            userOverlay.Markers.Add(user);

            GMapOverlay   startOverlay = new GMapOverlay("start");
            GMarkerGoogle startMarker  = new GMarkerGoogle(start,
                                                           GMarkerGoogleType.gray_small);

            startOverlay.Markers.Add(startMarker);

            GMapOverlay mapPointOverlay = new GMapOverlay("objects");
            GMapOverlay pokemonOverlay  = new GMapOverlay("pokemon");

            GMapOverlay areaOverlay = new GMapOverlay("area");
            //p_Settings.MaxTravelDistanceInMeters
            var areaMarker = Marker.CreateCircle(start, p_Settings.MaxTravelDistanceInMeters, 32);

            areaOverlay.Polygons.Add(areaMarker);

            gMapControl1.Overlays.Add(areaOverlay);
            gMapControl1.Overlays.Add(startOverlay);
            gMapControl1.Overlays.Add(mapPointOverlay);
            gMapControl1.Overlays.Add(pokemonOverlay);
            gMapControl1.Overlays.Add(userOverlay);
        }