Beispiel #1
0
    public void GenerateMarkers()
    {
        Response.Write("<script type=\"text/javascript\">\r\n");
        Response.Write("function addMarkers(){\r\n");

        if (parser != null && !string.IsNullOrEmpty(parser.SourceFile))
        {
            string thumbsFolder = PathFunctions.GetThumbsFolder(parser.SourceFile);

            foreach (WayPoint wp in parser.WayPoints)
            {
                bool hasPhoto =
                    !string.IsNullOrEmpty(wp.link) &&
                    wp.link.EndsWith(".jpg", StringComparison.InvariantCultureIgnoreCase);

                string color = hasPhoto
                    ? "blue"
                    : "red";

                string name        = wp.name.Replace("'", "\\'");
                string description = wp.description.Replace("'", "\\'");
                string icon        = hasPhoto
                    ? "/Images/camera_icon.png"
                    : "";
                string photo = hasPhoto
                    ? PathFunctions.GetUrlFromPath(Path.Combine(thumbsFolder, Path.GetFileName(wp.link)), false).Replace("'", "\\'")
                    : "";
                string url = hasPhoto
                    ? PathFunctions.GetUrlFromPath(wp.link, false).Replace("'", "\\'")
                    : "";
                Response.Write(string.Format(
                                   "GV_Draw_Marker({{ lat: {0}, lon: {1}, name: '{2}', desc: '{3}', color: '{4}', icon: '{5}', photo: '{6}', url: '{7}' }});\r\n",
                                   wp.lat.ToString(System.Globalization.CultureInfo.InvariantCulture),
                                   wp.lon.ToString(System.Globalization.CultureInfo.InvariantCulture),
                                   name,
                                   description,
                                   color,
                                   icon,
                                   photo,
                                   url));
            }
        }
        Response.Write("}\r\n");
        Response.Write("</script>\r\n");
    }