protected void AddMarker(EntidadPadre entidad, string style) { if (entidad != null) { var icono = IconDir; if (entidad.ReferenciaGeografica != null && entidad.ReferenciaGeografica.Icono != null) { icono += entidad.ReferenciaGeografica.Icono.PathIcono; } var desc = entidad.Descripcion; var refGeo = entidad.ReferenciaGeografica; var vehiculoAsociado = DAOFactory.CocheDAO.FindMobileByDevice(entidad.Dispositivo.Id); var ultimaPosicion = vehiculoAsociado != null?DAOFactory.LogPosicionDAO.GetLastVehiclesPositions(new List <Coche> { vehiculoAsociado })[vehiculoAsociado.Id] : null; var latitud = ultimaPosicion != null ? ultimaPosicion.Latitud : refGeo != null ? refGeo.Latitude : 0; var longitud = ultimaPosicion != null ? ultimaPosicion.Longitud : refGeo != null ? refGeo.Longitude : 0; var marker = MarkerFactory.CreateLabeledMarker(entidad.Id.ToString("#0"), icono, latitud, longitud, desc, style, GetMovilPopupContent(entidad)); if (refGeo != null && refGeo.Icono != null) { marker.Size = DrawingFactory.GetSize(refGeo.Icono.Width, refGeo.Icono.Height); marker.Offset = DrawingFactory.GetOffset(refGeo.Icono.OffsetX, refGeo.Icono.OffsetY); } Monitor.AddMarkers(LayerEntidades, marker); } }
private void GenerateMarkers() { var events = FilterEvents(); if (events == null) { return; } for (var i = 0; i < events.Count; i++) { Monitor.AddMarkers(Layers.Eventos, new Marker(i.ToString("#0"), GetIconUrl(events[i]), events[i].InitialLatitude, events[i].InitialLongitude, string.Format("javascript:gMP('{0}','{1}','{2}','{3}','{4:0.00}','{5}','{6}','{7}')", events[i].InitialLatitude.ToString(CultureInfo.InvariantCulture), events[i].InitialLongitude.ToString(CultureInfo.InvariantCulture), string.Concat(events[i].InitialDate.ToDisplayDateTime().ToShortDateString(), " ", events[i].InitialDate.ToDisplayDateTime().TimeOfDay.ToString()), events[i].ElapsedTime, events[i].Distance, events[i].MinimumSpeed, events[i].MaximumSpeed, Convert.ToInt32(events[i].AverageSpeed)), DrawingFactory.GetSize(24, 24), GetMarkerOffset(events[i]))); } var centerIndex = RouteCenterIndex; if (centerIndex == null) { return; } _x = events[centerIndex.Value].InitialLatitude; _y = events[centerIndex.Value].InitialLongitude; Monitor.TriggerEvent(centerIndex.ToString(), Layers.Eventos, PopupEvent); }
private void GetMessages() { var messages = lbMessages.SelectedStringValues; if (MessagesIds.Count == 0 && messages.Count == 0) { return; } var empresa = DAOFactory.EmpresaDAO.FindById(ddlDistrito.Selected); var maxMonths = empresa != null && empresa.Id > 0 ? empresa.MesesConsultaPosiciones : 3; var events = DAOFactory.LogMensajeDAO.GetByMobilesAndTypes(ddlMovil.SelectedValues, GetSelectedMessagesCodes(messages), InitialDate, FinalDate, maxMonths); for (var i = 0; i < events.Count(); i++) { var el = events.ElementAt(i); if (!el.HasValidLatitudes()) { continue; } var messageIconUrl = el.GetIconUrl(); var iconUrl = string.IsNullOrEmpty(messageIconUrl) ? Images.DefaultMessage : string.Concat(IconDir, messageIconUrl); Monitor.AddMarkers(Layers.Mensajes, new Marker(i.ToString("#0"), iconUrl, el.Latitud, el.Longitud, string.Format("javascript:gMSP({0})", el.Id), DrawingFactory.GetSize(24, 24), DrawingFactory.GetOffset(-12, -12))); //if (el.HasDuration()) AddMessageWithElapsedTime(el); } SetMessagesCenterIndex(events); }
private void AddFlags(IList <List <RoutePosition> > routes) { var start = routes[0][0]; var end = routes[routes.Count - 1][routes[routes.Count - 1].Count - 1]; var size = DrawingFactory.GetSize(40, 40); var offset = DrawingFactory.GetOffset(-20, -32); Monitor.AddMarkers(Layers.Eventos, new Marker(start.Date.ToDisplayDateTime().ToString(), Images.Start, start.Latitude, start.Longitude, string.Format("javascript:gFP('{0}')", string.Concat(start.Date.ToDisplayDateTime().ToShortDateString(), " ", start.Date.ToDisplayDateTime().TimeOfDay.ToString())), size, offset), new Marker(end.Date.ToDisplayDateTime().ToString(), Images.End, end.Latitude, end.Longitude, string.Format("javascript:gFP('{0}')", string.Concat(end.Date.ToDisplayDateTime().ToShortDateString(), " ", end.Date.ToDisplayDateTime().TimeOfDay.ToString())), size, offset)); }
public void AddMarkers() { var points = Points.Get(); if (points == null || points.Count == 0) { Monitor.ClearLayer(LayerMarkers); return; } var inicio = points.First(); var fin = points.Last(); var markIni = new Marker("inicio", ResolveUrl("~/images/salida.png"), inicio.Y, inicio.X, DrawingFactory.GetSize(32, 32), DrawingFactory.GetOffset(-16, -32)); var markFin = new Marker("fin", ResolveUrl("~/images/llegada.png"), fin.Y, fin.X, DrawingFactory.GetSize(32, 32), DrawingFactory.GetOffset(-16, -32)); Monitor.AddMarkers(LayerMarkers, markIni, markFin); }
private void GetReferenciasGeograficas() { var pois = !PoisTypesIds.Contains(0) ? DAOFactory.ReferenciaGeograficaDAO.GetList(new[] { Distrito }, new[] { Location }, PoisTypesIds).Where(x => x.Vigencia == null || x.Vigencia.Vigente(InitialDate, FinalDate)).ToList() : new List <ReferenciaGeografica>(); if (pois.Count == 0 && lstTicket.SelectedValue != "") { var value = lstTicket.SelectedValue.Contains("T-") || lstTicket.SelectedValue.Contains("V-") ? Convert.ToInt32((string)lstTicket.SelectedValue.Split('-')[1]) : Convert.ToInt32((string)lstTicket.SelectedValue); if (value > 0 && lstTicket.SelectedValue.Contains("T-")) { var ticket = DAOFactory.TicketDAO.FindById(value); pois.Add(ticket.Linea.ReferenciaGeografica); pois.Add(ticket.PuntoEntrega.ReferenciaGeografica); } if (value > 0 && lstTicket.SelectedValue.Contains("V-")) { var viaje = DAOFactory.ViajeDistribucionDAO.FindById(value); pois.Add(viaje.Linea.ReferenciaGeografica); pois.AddRange(viaje.Detalles.Select(detalle => detalle.ReferenciaGeografica)); } } foreach (var punto in pois) { if (punto.Poligono != null) { DrawGeocerca(punto); } if (punto.Direccion != null) { Monitor.AddMarkers(Layers.PuntosDeInteres, new Marker(punto.Id.ToString("#0"), GetPoiIcon(punto), punto.Direccion.Latitud, punto.Direccion.Longitud, string.Format("javascript:gPOIP('{0}')", punto.Descripcion), DrawingFactory.GetSize(24, 24), DrawingFactory.GetOffset(-12, -12))); } } }
/// <summary> /// Displays the last position reported by the givenn mobile or device. /// </summary> /// <param name="lastPosition"></param> private void DisplayPosition(MobilePosition lastPosition) { var id = lastPosition.IdPosicion.ToString(); var latitude = lastPosition.Latitud; var longitude = lastPosition.Longitud; var popup = string.Format("javascript:gPP('{0}','{1}','{2}','{3}','{4}','{5}')", lastPosition.EsquinaCercana, lastPosition.Interno, lastPosition.Responsable, lastPosition.Dispositivo, string.Concat(lastPosition.Fecha.Value.ToShortDateString(), "", lastPosition.Fecha.Value.TimeOfDay.ToString()), lastPosition.Velocidad); var marker = new Marker(id, CurrentPositionImgUrl, latitude, longitude, popup, DrawingFactory.GetSize(21, 25), DrawingFactory.GetOffset(-10.5, -25)); Monitor.AddMarkers(_posicion, marker); Monitor.SetCenter(latitude, longitude); Monitor.SetDefaultCenter(latitude, longitude); Monitor.TriggerEvent(id, _posicion, PopupEvent); }
private void GetReferenciasGeograficas() { var pois = !PoisTypesIds.Contains(0) ? DAOFactory.ReferenciaGeograficaDAO.GetList(new[] { Distrito }, new[] { Location }, PoisTypesIds).Where(x => x.Vigencia == null || x.Vigencia.Vigente(InitialDate, FinalDate)).ToList() : new List <ReferenciaGeografica>(); foreach (var punto in pois) { if (punto.Poligono != null) { DrawGeocerca(punto); } if (punto.Direccion != null) { Monitor.AddMarkers(Layers.PuntosDeInteres, new Marker(punto.Id.ToString("#0"), GetPoiIcon(punto), punto.Direccion.Latitud, punto.Direccion.Longitud, string.Format("javascript:gPOIP('{0}')", punto.Descripcion), DrawingFactory.GetSize(24, 24), DrawingFactory.GetOffset(-12, -12))); } } }
private void AddReferenciaGeografica(string layerPoi, string layerArea, ReferenciaGeografica dom, string popupContent) { if (dom.Poligono != null) { var center = dom.Poligono.FirstPoint; var col = StyleFactory.GetPointFromColor(dom.Color.Color); var id = dom.Id + "_GEO"; if (dom.Poligono.Radio > 0) { Monitor.AddGeometries(layerArea, new Point(id, center.X, center.Y, dom.Poligono.Radio, col)); } else { var points = dom.Poligono.ToPointFList(); var poly = new Polygon(id, col); for (var i = 0; i < points.Count; i++) { poly.AddPoint(new Point(id + "_" + i, points[i].X, points[i].Y)); } Monitor.AddGeometries(layerArea, poly); } } if (dom.Direccion == null) { return; } var icono = dom.Icono != null ? IconDir + dom.Icono.PathIcono : string.Empty; var marker = new Marker(dom.Id.ToString("#0"), icono, dom.Direccion.Latitud, dom.Direccion.Longitud, popupContent, DrawingFactory.GetSize(dom.Icono != null ? dom.Icono.Width : 0, dom.Icono != null ? dom.Icono.Height : 0), DrawingFactory.GetOffset(dom.Icono != null ? dom.Icono.OffsetX : 0, dom.Icono != null ? dom.Icono.OffsetY : 0)); Monitor.AddMarkers(layerPoi, marker); }
private void GetCenter(IEnumerable <List <RoutePosition> > routes) { var centerPosition = PosCenterIndex; if (centerPosition == null) { return; } foreach (var position in routes.SelectMany(route => route.Where(position => position.Id.Equals(centerPosition.Value)))) { Monitor.AddMarkers(Layers.Eventos, new Marker(position.Date.ToDisplayDateTime().ToString(), Images.CurrentPosition, position.Latitude, position.Longitude, string.Format("javascript:gCP('{0}', '{1}', '{2}')", GeocoderHelper.GetDescripcionEsquinaMasCercana(position.Latitude, position.Longitude), position.Date.ToDisplayDateTime(), position.Speed), DrawingFactory.GetSize(21, 25), DrawingFactory.GetOffset(-10.5, -25))); _x = position.Latitude; _y = position.Longitude; Monitor.TriggerEvent(position.Date.ToDisplayDateTime().ToString(), Layers.Eventos, PopupEvent); } }