|
18 | 18 | } |
19 | 19 | </style> |
20 | 20 | <title>RIT Map</title> |
| 21 | + <script src="https://cdnjs.cloudflare.com/ajax/libs/mustache.js/2.2.1/mustache.min.js"></script> |
21 | 22 |
|
22 | 23 | <!-- Plug in the map information --> |
23 | 24 | <script type = "text/javascript"> |
|
54 | 55 | // Insert the data. |
55 | 56 | for (i = 0; i < mapData.mapData.length; ++i) { |
56 | 57 | var data = mapData.mapData[i]; |
57 | | - var markerHTML = '<div class = "center" style="overflow:auto;color:black;">'; |
58 | | - markerHTML += '<p><strong>' + data.title + '</strong></p>'; |
59 | | - if (data.image != "") { |
60 | | - markerHTML += '<p><a href = "media/places/' + data.image + '" target = "_blank">'; |
61 | | - markerHTML += '<img src="media/places/' + data.image + '" alt="' + data.image + '"/></p></a>'; |
| 58 | + if (data.image === "") { |
| 59 | + data.image = "no_image.png"; |
62 | 60 | } |
63 | | - else { |
64 | | - markerHTML += '<p><a href="https://github.com/ritmap/ritmap.github.io#submitting-content" target="_blank">'; |
65 | | - markerHTML += '<img src="media/no_image.png" alt="no image"/></a></p>'; |
66 | | - } |
67 | | - markerHTML += '<p>' + data.desc + '</p>'; |
68 | | - markerHTML += '</div>'; |
69 | | - var popupOffset = L.point(0, 55); |
70 | | - var newPopup = L.popup({maxWidth:500, autoPanPaddingTopLeft: popupOffset}) |
| 61 | + |
| 62 | + var markerHTML = |
| 63 | + Mustache.render( |
| 64 | + '<div class="center" \ |
| 65 | + style="overflow:auto;color:black;">\ |
| 66 | + <p><strong>{{title}}</strong></p>\ |
| 67 | + <p><a href="media/places/{{image}}"\ |
| 68 | + target="_blank"><img src="media/places/{{image}}"\ |
| 69 | + alt="{{image}}" />\ |
| 70 | + </a></p>\ |
| 71 | + <p>{{{desc}}}</p>\ |
| 72 | + </div>', |
| 73 | + data |
| 74 | + ); |
| 75 | + |
| 76 | + var popupOffset = L.point(0, 55); |
| 77 | + var newPopup = L.popup({maxWidth:500, autoPanPaddingTopLeft: popupOffset}) |
71 | 78 | .setContent(markerHTML); |
72 | 79 |
|
73 | 80 | var newMarker = L.marker([data.lat, data.lon]) |
|
0 commit comments