public static string GetMapWithMarkersAndPolylines(Journey journey)
        {
            var stops = journey.GetStops();
            var map   = stops.CreateMap("map", stops.GetAverageLatitude(), stops.GetAverageLongitude(), 15);

            var initMap = new JavascriptFunction.Definition("initMap");

            initMap.AddInstruction(map.VariableAssignment);
            initMap.AddInstruction(stops.CreateMarkers(map).ToString);

            for (int i = 0; i < journey.JourneySegments.Count; i++)
            {
                var js = journey.JourneySegments[i];

                if (js is TripSegment)
                {
                    initMap.AddInstruction(((TripSegment)js).GetStops().CreateSimplePolyline(map, 4.0, ((TripSegment)js).LineColor, false, i).ToString);
                }

                else
                {
                    initMap.AddInstruction(((FootpathSegment)js).GetStops().CreateSimplePolyline(map, 4.0, Timetables.Utilities.CPColor.Gray, true, i).ToString);
                }
            }

            return(GetHtmlStringConstant(initMap.ToString(), initMap.FunctionName));
        }
        public static string GetMapWithMarkersAndPolylines(Departure departure)
        {
            var stops = departure.GetStops();
            var map   = stops.CreateMap("map", stops.GetAverageLatitude(), stops.GetAverageLongitude(), 13);

            var initMap = new JavascriptFunction.Definition("initMap");

            initMap.AddInstruction(map.VariableAssignment);
            initMap.AddInstruction(stops.CreateMarkers(map).ToString);
            initMap.AddInstruction(stops.CreateSimplePolyline(map, 4.0, departure.LineColor).ToString);

            return(GetHtmlStringConstant(initMap.ToString(), initMap.FunctionName));
        }
        public static string GetMapWithMarkers(this IEnumerable <StopsBasic.StopBasic> stops)
        {
            double lat, lon;
            int    zoom;

            Position loc = new Position();

            try
            {
                loc = AsyncHelpers.RunSync <Position>(DataFeedClient.GeoWatcher.GetCurrentPosition);
            }
            catch
            {
            }

            if (double.IsNaN(loc.Latitude) || double.IsNaN(loc.Longitude))
            {
                lat  = stops.GetAverageLatitude();
                lon  = stops.GetAverageLongitude();
                zoom = 15;
            }
            else
            {
                lat  = loc.Latitude;
                lon  = loc.Longitude;
                zoom = 17;
            }


            var map     = stops.CreateMap("map", lat, lon, zoom);
            var initMap = new JavascriptFunction.Definition("initMap");


            initMap.AddInstruction(map.VariableAssignment);
            initMap.AddInstruction(stops.CreateMarkers(map, true).ToString);

            return(GetHtmlStringConstant(initMap.ToString(), initMap.FunctionName));
        }