Created
March 15, 2018 09:24
-
-
Save deanhume/2a2c88a6f963b6eb629dfa94e0c72d6e to your computer and use it in GitHub Desktop.
DrawMap
This file contains 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
/// <summary> | |
/// Draws the map. | |
/// </summary> | |
/// <param name="helper">The helper.</param> | |
/// <param name="key">The key.</param> | |
/// <param name="jsonUrl">The json URL.</param> | |
/// <param name="mapWidth">Width of the map.</param> | |
/// <param name="mapHeight">Height of the map.</param> | |
/// <returns>The html of the map.</returns> | |
public static string DrawMap(this HtmlHelper helper, string key, string jsonUrl, string mapWidth, string mapHeight) | |
{ | |
StringBuilder mapHtml = new StringBuilder(); | |
// Google Maps API Link | |
mapHtml.Append("<script src=\\"http://maps.google.com/maps"); | |
mapHtml.Append("?file=api&v=2&sensor=false&key="); | |
mapHtml.Append(key); | |
mapHtml.Append("\\" type=\\"text/javascript\\"></script>"); | |
// Hidden value | |
mapHtml.Append("<input type=\\"hidden\\" "); | |
mapHtml.Append("id=\\"MarkerUrl\\" value=\\""); | |
mapHtml.Append(jsonUrl); | |
mapHtml.Append("\\" />"); | |
// Map Div | |
mapHtml.Append("<div id=\\"map\\" style=\\"width: "); | |
mapHtml.Append(mapWidth); | |
mapHtml.Append("px; height: "); | |
mapHtml.Append(mapHeight); | |
mapHtml.Append("px\\"></div>"); | |
// Maps javascript file | |
mapHtml.Append("<script type=\\"text/javascript\\" "); | |
mapHtml.Append("src=\\"/Content/GoogleMapping.js\\"></script>"); | |
return mapHtml.ToString(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment