Error executing template "Designs/Swift/Paragraph/Swift_LocationsMap.cshtml" System.InvalidOperationException: A prior operation on this collection was interrupted by an exception. Collection's state is no longer trusted. at System.Runtime.CompilerServices.ConditionalWeakTable`2.Container.VerifyIntegrity() at System.Runtime.CompilerServices.ConditionalWeakTable`2.Container.CreateEntryNoResize(TKey key, TValue value) at System.Runtime.CompilerServices.ConditionalWeakTable`2.Add(TKey key, TValue value) at Microsoft.AspNetCore.Razor.Language.Syntax.InternalSyntax.MarkupTextLiteralSyntax.SetAnnotations(SyntaxAnnotation[] annotations) at Microsoft.AspNetCore.Razor.Language.Legacy.TokenizerBackedParser`1.GetNodeWithSpanContext[TNode](TNode node) at Microsoft.AspNetCore.Razor.Language.Legacy.HtmlMarkupParser.OtherParserBlock(SyntaxListBuilder`1& builder) at Microsoft.AspNetCore.Razor.Language.Legacy.HtmlMarkupParser.ParseDocument() at Microsoft.AspNetCore.Razor.Language.Legacy.RazorParser.Parse(RazorSourceDocument source) at Microsoft.AspNetCore.Razor.Language.DefaultRazorEngine.Process(RazorCodeDocument document) at Microsoft.AspNetCore.Razor.Language.RazorTemplateEngine.GenerateCode(RazorCodeDocument codeDocument) at RazorEngine.Compilation.CompilerServiceBase.GenerateCodeFile(RazorTemplateEngine templateEngine, RazorCodeDocument document) at RazorEngine.Compilation.CompilerServiceBase.GetGeneratorResult(IEnumerable`1 namespaces, TypeContext context) at RazorEngine.Compilation.CompilerServiceBase.GetCodeCompileUnit(TypeContext context) at Dynamicweb.Rendering.Compatibility.RoslynCompilerServiceBase.CompileType(TypeContext context) at RazorEngine.Templating.RazorEngineCore.CreateTemplateType(ITemplateSource razorTemplate, Type modelType) at RazorEngine.Templating.RazorEngineCore.Compile(ITemplateKey key, Type modelType) at RazorEngine.Templating.RazorEngineService.CompileAndCacheInternal(ITemplateKey key, Type modelType) at RazorEngine.Templating.RazorEngineService.GetCompiledTemplate(ITemplateKey key, Type modelType, Boolean compileOnCacheMiss) at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.DynamicWrapperService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.RazorEngineServiceExtensions.RunCompile(IRazorEngineService service, String name, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer) at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter) at RazorEngine.Templating.RazorEngineServiceExtensions.RunCompile(IRazorEngineService service, String name, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.RazorEngineServiceExtensions.RunCompile(IRazorEngineService service, String templateSource, String name, Type modelType, Object model, DynamicViewBag viewBag) at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template) at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template) at Dynamicweb.Rendering.Template.RenderRazorTemplate()
1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 3 @{ 4 string apiKey = !string.IsNullOrEmpty(Pageview.AreaSettings.GetString("Google_APIKey")) ? Pageview.AreaSettings.GetString("Google_APIKey") : ""; 5 var locationList = Model.Item.GetUsers("UserGroup"); 6 string iconPath = "/Files/Templates/Designs/Swift/Assets/icons/"; 7 int initialZoomLevel = !string.IsNullOrEmpty(Model.Item.GetString("InitialZoomLevel")) ? Model.Item.GetInt32("InitialZoomLevel") : 4; 8 initialZoomLevel = initialZoomLevel == 0 ? 4 : initialZoomLevel; 9 string regionCode = !string.IsNullOrEmpty(Model.Item.GetString("RegionCode")) ? Model.Item.GetString("RegionCode") : "DK"; 10 bool useDefaultGoogleMapsStyling = !string.IsNullOrEmpty(Model.Item.GetString("UseDefaultGoogleMapsStyling")) ? Model.Item.GetBoolean("UseDefaultGoogleMapsStyling") : false; 11 12 var defaultLat = Model.Item?.GetGeolocation("DefaultMapCenter")?.Latitude != null ? Model.Item.GetGeolocation("DefaultMapCenter").Latitude.ToString().Replace(",", ".") : "0.000000"; 13 var defaultLng = Model.Item?.GetGeolocation("DefaultMapCenter")?.Longitude != null ? Model.Item.GetGeolocation("DefaultMapCenter").Longitude.ToString().Replace(",", ".") : "0.000000"; 14 string theme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("Theme")) ? " theme " + Model.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : ""; 15 16 string headingLevel = Model.Item.GetString("HeadingLevel", "h2"); 17 string headingLevelStart = $"<{headingLevel} class=\"h1 m-0\">"; 18 string headingLevelStop = $"</{headingLevel}>"; 19 } 20 21 @if (defaultLat != "0.000000" && defaultLng != "0.000000") { 22 if (apiKey != "") { 23 <div class="grid position-relative@(theme) item_@Model.Item.SystemName.ToLower()"> 24 <div id="@Model.ID" class="user-select-none position-absolute" style="scroll-margin-top:var(--header-height,150px)"></div> 25 @if (!string.IsNullOrEmpty(Model.Item.GetString("Title")) && !Model.Item.GetBoolean("HideTitle")) { 26 <div class="g-col-12 g-col-lg-8 order-1" id="MapHeader"> 27 @headingLevelStart 28 @Model.Item.GetString("Title") 29 @headingLevelStop 30 </div> 31 } else { 32 <div class="g-col-12 g-col-lg-8 order-1" id="MapHeader"></div> 33 } 34 <div class="g-col-12 g-col-lg-4 order-2 order-lg-2 position-relative js-map-search-column"> 35 <form class="d-flex align-items-center w-100" id="MapSearch"> 36 <span class="position-absolute top-0 icon-2 px-3 d-flex align-items-center h-100 search-icon"> 37 @ReadFile(iconPath + "search.svg") 38 </span> 39 40 <input type="text" class="form-control rounded-pill py-2 ps-5 pe-3" placeholder="@Translate("Enter city state or zip")"> 41 <button type="submit" class="d-none" id="MapSearchButton">@Translate("Search")</button> 42 </form> 43 </div> 44 45 <div class="g-col-12 g-col-lg-8 order-1 order-lg-4 js-map-column"> 46 <div class="map" id="Map"></div> 47 </div> 48 49 @if (locationList.Count() > 1) { 50 <div class="g-col-12 g-col-lg-4 order-2 order-lg-3 js-locations-list-column"> 51 <div class="locations-list"> 52 <ul class="list-group" id="LocationsList"></ul> 53 </div> 54 </div> 55 } else if (!string.IsNullOrEmpty(Model.Item.GetString("Title")) && !Model.Item.GetBoolean("HideTitle")) { 56 <div class="g-col-12 order-5 order-lg-3"> 57 @headingLevelStart 58 @Model.Item.GetString("Title") 59 @headingLevelStop 60 </div> 61 } 62 </div> 63 } 64 else { 65 <div class="alert alert-info" role="alert"> 66 @Translate("Google maps API key is missing") 67 </div> 68 } 69 70 <script type="module"> 71 @if (!useDefaultGoogleMapsStyling) { 72 <text> 73 var mapIcon = { 74 url: "@(iconPath)marker.svg" 75 } 76 77 var mapStyle = [ 78 { 79 "featureType": "administrative.land_parcel", 80 "elementType": "labels", 81 "stylers": [ 82 { 83 "visibility": "off" 84 } 85 ] 86 }, 87 { 88 "featureType": "landscape.man_made", 89 "elementType": "geometry.fill", 90 "stylers": [ 91 { 92 "color": "#b0afb6" 93 } 94 ] 95 }, 96 { 97 "featureType": "landscape.natural", 98 "elementType": "geometry.fill", 99 "stylers": [ 100 { 101 "color": "#d7d7da" 102 } 103 ] 104 }, 105 { 106 "featureType": "landscape.natural.terrain", 107 "elementType": "geometry.fill", 108 "stylers": [ 109 { 110 "color": "#7ba78b" 111 } 112 ] 113 }, 114 { 115 "featureType": "poi", 116 "elementType": "labels.text", 117 "stylers": [ 118 { 119 "visibility": "off" 120 } 121 ] 122 }, 123 { 124 "featureType": "poi", 125 "elementType": "geometry", 126 "stylers": [ 127 { 128 "color": "#659577" 129 } 130 ] 131 }, 132 { 133 "featureType": "poi.business", 134 "stylers": [ 135 { 136 "visibility": "off" 137 } 138 ] 139 }, 140 { 141 "featureType": "poi.park", 142 "elementType": "geometry.fill", 143 "stylers": [ 144 { 145 "color": "#659577" 146 } 147 ] 148 }, 149 { 150 "featureType": "road", 151 "elementType": "labels.icon", 152 "stylers": [ 153 { 154 "visibility": "off" 155 } 156 ] 157 }, 158 { 159 "featureType": "road.highway", 160 "elementType": "geometry.fill", 161 "stylers": [ 162 { 163 "color": "#f5f5f5" 164 } 165 ] 166 }, 167 { 168 "featureType": "road.highway", 169 "elementType": "geometry.stroke", 170 "stylers": [ 171 { 172 "color": "#f0f0f0" 173 } 174 ] 175 }, 176 { 177 "featureType": "road.local", 178 "elementType": "labels", 179 "stylers": [ 180 { 181 "visibility": "off" 182 } 183 ] 184 }, 185 { 186 "featureType": "transit", 187 "stylers": [ 188 { 189 "visibility": "off" 190 } 191 ] 192 }, 193 { 194 "featureType": "water", 195 "elementType": "geometry.fill", 196 "stylers": [ 197 { 198 "color": "#8ea5c2" 199 } 200 ] 201 } 202 ]; 203 </text> 204 } else { 205 <text> 206 var mapIcon = {}; 207 208 var mapStyle = [{ 209 featureType: 'poi', 210 elementType: 'labels.icon', 211 stylers: [ 212 { 213 visibility: 'off' 214 } 215 ] 216 }]; 217 </text> 218 } 219 220 var locations = [ 221 @foreach (var location in locationList) { 222 <text>{ 223 name: "@(location.Name)", 224 company: "@(location.Company)", 225 address: "@(location.Address)", 226 city: "@(location.City)", 227 zip: "@(location.Zip)", 228 state: "@(location.State)", 229 country: "@(location.Country)", 230 phone: "@(location.Phone)", 231 email: "@(location.Email)", 232 location: { 233 lat: @(location.Location.Lat.ToString().Replace(",", ".")), 234 lng: @(location.Location.Lng.ToString().Replace(",", ".")) 235 } 236 },</text> 237 } 238 ]; 239 240 var mapSettings = { 241 locations: locations, 242 mapStyle: mapStyle, 243 mapIcon: mapIcon, 244 initialZoomLevel: @initialZoomLevel, 245 defaultLat: @defaultLat, 246 defaultLng: @defaultLng, 247 regionCode: "@(regionCode)", 248 directionsLabel: "@Translate("Directions")", 249 noLocationsFoundLabel: "@Translate("No options available in the selected area")" 250 }; 251 252 window.addEventListener('DOMContentLoaded', function (event) { 253 swift.LocationsMap.init(mapSettings); 254 }); 255 </script> 256 257 <script defer src="https://maps.googleapis.com/maps/api/js?key=@(apiKey)"></script> 258 } else { 259 <div class="alert alert-info" role="alert"> 260 @Translate("The map is not proberly configured") 261 </div> 262 } 263