Ejemplo n.º 1
0
        private void gmcCarte_OnMapClick(PointLatLng pointClick, MouseEventArgs e)
        {
            if (nomPointInteret != string.Empty && visitePointInteret != string.Empty && descriptionPointInteret != string.Empty)
            {
                PointInteret nouveauPointInteret = new PointInteret(pointClick.Lat.ToString().Replace(',', '.'), pointClick.Lng.ToString().Replace(',', '.'), nomPointInteret, visitePointInteret, descriptionPointInteret);
                pointsInterets.Add(nouveauPointInteret);
                AjouterMarqueurCarte(pointClick, overlayMarkers, GMarkerGoogleType.green_dot, nouveauPointInteret);

                //Ajout à la BDD
                bd.maConnexion.Open();
                bd.CreerPointInteret(nouveauPointInteret);
                bd.maConnexion.Close();

                //Reset des valeurs pour ne pas pouvoir ajouter intentionnellement plusieurs fois
                //de suite un marqueur contenant les mêmes informations mais à des endroits différents
                nomPointInteret         = string.Empty;
                visitePointInteret      = string.Empty;
                descriptionPointInteret = string.Empty;

                //Reset des champs de l'ajout du marqueur
                tbxNomPointInteret.Text             = "";
                cbxVisitePointInteret.SelectedIndex = 0;
                tbxDescriptionPointInteret.Text     = "";

                //Supprimer et ajouter la couche pour rafraichir l'affichage
                gmcCarte.Overlays.Clear();
                gmcCarte.Overlays.Add(overlayMarkers);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Crée un point d'intérêt dans la base de données
        /// </summary>
        /// <param name="pointInteret"></param>
        public void CreerPointInteret(PointInteret pointInteret)
        {
            //Remplacer les ' par des double '' pour éviter les erreurs avec le SQL
            string query = string.Format("INSERT INTO pointInteret (lat, lng, nom, visite, description) " +
                                         "VALUES ('{0}', '{1}', '{2}', '{3}', '{4}');", pointInteret.Lat, pointInteret.Lng, pointInteret.Nom.Replace("'", "''"), pointInteret.Visite, pointInteret.Description.Replace("'", "''"));

            SQLiteCommand sQLiteCommand = new SQLiteCommand(query, maConnexion);

            sQLiteCommand.ExecuteNonQuery();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Ajoute le point d'intérêt fournit en paramètre sur la carte
        /// </summary>
        /// <param name="latLng">Position du marqueur</param>
        /// <param name="overlayMarkers">La couche sur lequel ajouter le marqueur</param>
        /// <param name="style">Style du marqueur</param>
        /// <param name="pointInteret">PointInteret</param>
        private void AjouterMarqueurCarte(PointLatLng latLng, GMapOverlay overlayMarkers, GMarkerGoogleType style, PointInteret pointInteret)
        {
            //Crée le marqueur sur une carte avec les bonnes coordonées et un avec un certain style
            GMapMarker marqueur = new GMarkerGoogle(latLng, style);

            string infos = string.Empty;

            infos  = "Nom: " + pointInteret.Nom + "\r\n";
            infos += "Lieu visité: " + pointInteret.Visite + "\r\n";
            infos += "Description: " + pointInteret.Description + "\r\n";

            //Ajoute du texte à la bulle du marqueur lors du "hover" avec la souris sur le marqueur
            marqueur.ToolTipText = infos;

            //Ajouter le marker à la couche
            overlayMarkers.Markers.Add(marqueur);
        }