private void InicializarDatos() { SerializadorJson Serializador = SerializadorJson.GetInstancia(); object[] objetosResultante = (object[])Serializador.GetDatosDelArchivoJson("Lugares"); for (int i = 0; i < objetosResultante.Length; i++) { Dictionary <string, object> datos = (Dictionary <string, object>)objetosResultante[i]; GMarkerGoogle Marcador = new GMarkerGoogle(new PointLatLng(Convert.ToDouble(datos["Latitud"]), Convert.ToDouble(datos["Longitud"])), GMarkerGoogleType.green); Marcador.ToolTipMode = MarkerTooltipMode.OnMouseOver; Marcador.ToolTip = new GMapRoundedToolTip(Marcador); Brush ColorFondoInformacion = new SolidBrush(Color.Blue); Font letra = new Font("Arial", 12, FontStyle.Bold); ColorFondoInformacion.GetType(); Marcador.ToolTip.Stroke.Color = Color.Red; Marcador.ToolTip.TextPadding = new Size(5, 10); Marcador.ToolTip.Font = letra; Marcador.ToolTip.Fill = ColorFondoInformacion; ColorFondoInformacion = new SolidBrush(Color.White); Marcador.ToolTip.Foreground = ColorFondoInformacion; Marcador.ToolTipText = String.Format(" \n" + datos["Nombre"].ToString()); Marcador.Tag = datos["Nombre"]; this.gMapControl1.Overlays[1].Markers.Add(Marcador); this.Gestor.InsertarVertice(datos["Nombre"].ToString(), Convert.ToDouble(datos["Longitud"]), Convert.ToDouble(datos["Latitud"])); } MarcartRutas(); }
private void TrasarRutMasCaminoCorto(GMapMarker pMarcador) { GMarkerGoogle Marcador; Brush ColorFondoInformacion = new SolidBrush(Color.Red); Font f = new Font("Arial", 7, FontStyle.Bold); string result = ""; switch (this.vgContadorIndicadoresDeRuta) { case 0: this.vgContadorIndicadoresDeRuta++; this.vgMarcadorA = pMarcador; Marcador = new GMarkerGoogle(this.vgMarcadorA.Position, GMarkerGoogleType.blue); Marcador.Tag = pMarcador.Tag; Marcador.ToolTipMode = MarkerTooltipMode.Always; Marcador.ToolTip = new GMapRoundedToolTip(Marcador); ColorFondoInformacion.GetType(); Marcador.ToolTip.Stroke.Width = 2; Marcador.ToolTip.Stroke.Color = Color.Black; Marcador.ToolTip.TextPadding = new Size(5, 5); Marcador.ToolTip.Font = f; Marcador.ToolTip.Fill = ColorFondoInformacion; ColorFondoInformacion = new SolidBrush(Color.White); Marcador.ToolTip.Foreground = ColorFondoInformacion; Marcador.ToolTipText = String.Format("\nPunto A"); this.vgCapaMarcadores.Markers.Add(Marcador); this.gMapControl1.Overlays[2] = this.vgCapaMarcadores; break; case 1: this.vgContadorIndicadoresDeRuta++; this.vgMarcadorB = pMarcador; List <Lugar> listaCaminoMinimo = this.Gestor.GetRutaMinimaDijkstra(this.vgMarcadorA.Tag.ToString(), this.vgMarcadorB.Tag.ToString()); if (listaCaminoMinimo != null) { result = MarcarRuta(listaCaminoMinimo); Marcador = new GMarkerGoogle(this.vgMarcadorB.Position, GMarkerGoogleType.blue); Marcador.Tag = pMarcador.Tag; Marcador.ToolTipMode = MarkerTooltipMode.Always; Marcador.ToolTip = new GMapRoundedToolTip(Marcador); ColorFondoInformacion.GetType(); Marcador.ToolTip.Stroke.Color = Color.Black; Marcador.ToolTip.TextPadding = new Size(5, 5); Marcador.ToolTip.Font = f; Marcador.ToolTip.Fill = ColorFondoInformacion; ColorFondoInformacion = new SolidBrush(Color.White); Marcador.ToolTip.Foreground = ColorFondoInformacion; Marcador.ToolTipText = String.Format("\nPunto B"); this.vgCapaMarcadores.Markers.Add(Marcador); this.gMapControl1.Overlays[2] = this.vgCapaMarcadores; this.textDatosVerticeBuscado.Text = result; } else { if (this.vgMarcadorA.Tag.ToString().Equals(this.vgMarcadorB.Tag.ToString())) { result = "el punto de inicio y final es el mismo"; } MessageBox.Show("Ocurrio un error " + result); this.gMapControl1.Overlays[2].Clear(); } this.vgContadorIndicadoresDeRuta = 0; this.vgTrazarRuta = false; this.btnLlegar.Enabled = true; this.btnLlegar.BackColor = Color.MediumSeaGreen; break; } RefrecarMapa(); }
private void TrasarRutaArco(GMapMarker pMarcador) { GMarkerGoogle Marcador; string result = "\n"; Brush ColorFondoInformacion = new SolidBrush(Color.Red); Font f = new Font("Arial", 7, FontStyle.Bold); switch (this.vgContadorIndicadoresDeRuta) { case 0: this.vgContadorIndicadoresDeRuta++; this.vgMarcadorA = pMarcador; Marcador = new GMarkerGoogle(this.vgMarcadorA.Position, GMarkerGoogleType.blue); Marcador.Tag = pMarcador.Tag; Marcador.ToolTipMode = MarkerTooltipMode.Always; Marcador.ToolTip = new GMapRoundedToolTip(Marcador); ColorFondoInformacion.GetType(); Marcador.ToolTip.Stroke.Width = 2; Marcador.ToolTip.Stroke.Color = Color.Black; Marcador.ToolTip.TextPadding = new Size(5, 5); Marcador.ToolTip.Font = f; Marcador.ToolTip.Fill = ColorFondoInformacion; ColorFondoInformacion = new SolidBrush(Color.White); Marcador.ToolTip.Foreground = ColorFondoInformacion; Marcador.ToolTipText = String.Format("\nPunto A"); this.vgCapaMarcadores.Markers.Add(Marcador); this.gMapControl1.Overlays[2] = this.vgCapaMarcadores; break; case 1: this.vgContadorIndicadoresDeRuta++; this.vgMarcadorB = pMarcador; Arista <Lugar> arco = this.Gestor.GetArco(this.vgMarcadorA.Tag.ToString(), this.vgMarcadorB.Tag.ToString()); if (arco != null) { List <Lugar> listaLugares = new List <Lugar> { arco.GetVertA().Info, arco.GetVertB().Info }; MarcarRuta(listaLugares); Marcador = new GMarkerGoogle(this.vgMarcadorB.Position, GMarkerGoogleType.blue); Marcador.Tag = pMarcador.Tag; Marcador.ToolTipMode = MarkerTooltipMode.Always; Marcador.ToolTip = new GMapRoundedToolTip(Marcador); ColorFondoInformacion.GetType(); Marcador.ToolTip.Stroke.Color = Color.Black; Marcador.ToolTip.TextPadding = new Size(5, 5); Marcador.ToolTip.Font = f; Marcador.ToolTip.Fill = ColorFondoInformacion; ColorFondoInformacion = new SolidBrush(Color.White); Marcador.ToolTip.Foreground = ColorFondoInformacion; Marcador.ToolTipText = String.Format("\nPunto B"); this.vgCapaMarcadores.Markers.Add(Marcador); this.gMapControl1.Overlays[2] = this.vgCapaMarcadores; result += "Punto A: " + arco.GetVertA().Info.GetNombre() + "\n"; result += "Punto B: " + arco.GetVertB().Info.GetNombre() + "\n"; result += "Peso: " + arco.GetPeso() + " Metros"; this.textDatosVerticeBuscado.Text = result; } else { if (arco == null) { result = "el punto de inicio y final no son un arco"; } MessageBox.Show("Ocurrio un error " + result); this.gMapControl1.Overlays[2].Clear(); } this.vgContadorIndicadoresDeRuta = 0; this.vgVerArco = false; this.btnVerArco.Enabled = true; this.btnVerArco.BackColor = Color.MediumSeaGreen; break; } RefrecarMapa(); }