Click here to Skip to main content
15,120,268 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hello All,
This is the first time I am posting on this site, I tried to correct my message to be more clear, I need your help, let me explain my problem, my goal is to locate service stations in a city and see their markers with info bubble containing private information

I used : gmapControl en ajoutant GMap.NET.WindowsForms.dll

SQL
- The horizontal zoom bar is not visible
- When I seek a point, I could not choose the most adequate zoom to display maximum detail on item sought


C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Windows.Media.Imaging;
using GMap.NET;
using GMap.NET.MapProviders;
using GMap.NET.WindowsForms;
using GMap.NET.WindowsForms.Markers;
using System.Windows.Media;
 
 
namespace Région_Kenitra_Services
{
    public partial class FMainStations : Form
    {
        GMapOverlay overlayOne;
 
        public FMainStations()
        {
            InitializeComponent();
            cmbStation.SelectedIndex = 4;
        }
 
 
 
        private void FMainStations_Load(object sender, EventArgs e)
        {
            gMap.MapProvider = GMap.NET.MapProviders.GoogleMapProvider.Instance;
            GMap.NET.GMaps.Instance.Mode = GMap.NET.AccessMode.ServerAndCache;
            gMap.SetCurrentPositionByKeywords("K, M");
 
            gMap.CanDragMap = true;
            gMap.DragButton = MouseButtons.Left;
            //gMap.Zoom = gMap.MinZoom + 1;
            gMap.Dock = System.Windows.Forms.DockStyle.Fill;
            gMap.MouseWheelZoomType = MouseWheelZoomType.MousePositionAndCenter;
 
            //ajout des overlay
            overlayOne = new GMapOverlay(gMap, "OverlayOne");
            //ajout de Markers
            overlayOne.Markers.Add(new GMap.NET.WindowsForms.Markers.GMapMarkerCross
                (new PointLatLng(34.3252919244273, -6.5533447265635)));
 
 
            //ajout de overlay à la map
            gMap.Overlays.Add(overlayOne);
            gMap.ZoomAndCenterMarkers(overlayOne.Id);
 
         }
 
        private void gMap_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            double lat = 0,lng = 0 ;
 
            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                 lat = gMap.FromLocalToLatLng(e.X, e.Y).Lat;
                 lng = gMap.FromLocalToLatLng(e.X, e.Y).Lng;
            }
            MessageBox.Show(("Point : "+lat+"/"+lng));
        }
 
        private void btnImg_Click(object sender, EventArgs e)
        {/*
            try
            {
                ImageSource img = gMap.ToImageSource();
                PngBitmapEncoder en = new PngBitmapEncoder();
                en.Frames.Add(BitmapFrame.Create(img as BitmapSource));
 
                Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
                dlg.FileName = "GMap.NET Image"; // Default file name
                dlg.DefaultExt = ".png"; // Default file extension
                dlg.Filter = "Image (.png)|*.png"; // Filter files by extension
                dlg.AddExtension = true;
                dlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
 
                // Show save file dialog box
                bool? result = dlg.ShowDialog();
 
                // Process save file dialog box results
                if (result == true)
                {
                    // Save document
                    string filename = dlg.FileName;
 
                    using (System.IO.Stream st = System.IO.File.OpenWrite(filename))
                    {
                        en.Save(st);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }*/
        }
 
        private void btnOK_Click(object sender, EventArgs e)
        {
            gMap.MaxZoom = 30;
 
            string adresse1, adresse2, adresse3, adresse4 = "";
            double lat1, lat2, lat3, lat4 = 0;
            double lng1, lng2, lng3, lng4 = 0;
 
            adresse1 = "Station 1 \n Hôtel La Rotonde, \n Rue Mohamed Diouri,\n Kénitra, Maroc";
            lat1 = 34.2563970;
            lng1 = -6.5827260;
 
            
            overlayOne.Markers.Clear();
            MarkerTooltipMode mode = MarkerTooltipMode.Always;
            System.Drawing.Brush ToolTipBackColor = new SolidBrush(System.Drawing.Color.Coral);
 
            if (cmbStation.SelectedIndex.ToString() == "0")
            {
                gMap.Position = new PointLatLng(lat1, lng1);
                GMapMarkerGoogleRed marker = new GMapMarkerGoogleRed(gMap.Position);
 
                marker.ToolTip = new GMap.NET.WindowsForms.ToolTips.GMapBaloonToolTip(marker);
                marker.ToolTip.Format.Alignment = StringAlignment.Center;
                marker.ToolTipMode = mode;
                marker.ToolTip.Fill = ToolTipBackColor;
                marker.ToolTipText = adresse1.ToString();
                overlayOne.Markers.Add(marker);
                gMap.Overlays.Add(overlayOne);
 
            }
 
           
        }
    }
}


I need your help ..pls correct me
Posted
Updated 3-May-14 10:27am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900