Created
June 29, 2018 09:51
-
-
Save riccardopirani/63f81d31747b98a51ce9586b89a6547c to your computer and use it in GitHub Desktop.
C# display blue map on Gmap.net
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private void buttonCarica_Click(object sender, EventArgs e) | |
| { | |
| if (comboBoxUtenti.Text != "") | |
| { | |
| MapControlRisorse.MapProvider = GMapProviders.GoogleMap; | |
| Utente utemp = new Utente(comboBoxUtenti.Text); | |
| MarcaTempo tm = new MarcaTempo(utemp); | |
| DataTable dt = tm.CaricaRisorsa(dateTimePickerDataRisorse.Value.Date); | |
| if (dt.Rows.Count == 0) | |
| { | |
| MessageBox.Show("\n ATTENZIONE: "+ dateTimePickerDataRisorse.Value.Date); | |
| } | |
| else | |
| { | |
| int conta = 0; | |
| GMapOverlay markersOverlay = new GMapOverlay("markers"); | |
| foreach (DataRow dr in dt.Rows) | |
| { | |
| double lat = Convert.ToDouble(dr["Latitudine"].ToString().Replace(".", ",")); | |
| double lon = Convert.ToDouble(dr["Longitudine"].ToString().Replace(".", ",")); | |
| MapControlRisorse.Position = new GMap.NET.PointLatLng(lat, lon); | |
| //Verifico se l'utente ha segnato un ingresso o un uscita | |
| //Se è entrato il marker sarà verde se è uscito sarà rosso | |
| if (dr["Stato"].ToString() == "Ingresso") | |
| { | |
| GMarkerGoogle marker = new GMarkerGoogle(new GMap.NET.PointLatLng(lat, lon), GMarkerGoogleType.green); | |
| marker.ToolTipText = "" + dr["Utente"].ToString(); | |
| markersOverlay.Markers.Add(marker); | |
| // MapControlRisorse.Overlays.Add(markersOverlay); | |
| } | |
| else if (dr["Stato"].ToString() == "Uscita") | |
| { | |
| GMarkerGoogle marker = new GMarkerGoogle(new GMap.NET.PointLatLng(lat, lon), GMarkerGoogleType.red); | |
| marker.ToolTipText = "" + dr["Utente"].ToString(); | |
| markersOverlay.Markers.Add(marker); | |
| // MapControlRisorse.Overlays.Add(markersOverlay); | |
| } | |
| } | |
| MapControlRisorse.Overlays.Add(markersOverlay); | |
| MapControlRisorse.MinZoom = 5; | |
| MapControlRisorse.MaxZoom = 100; | |
| MapControlRisorse.Zoom = 10; | |
| MapControlRisorse.MouseWheelZoomEnabled = true; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment