本文整理汇总了C#中LocationCollection.AsJson方法的典型用法代码示例。如果您正苦于以下问题:C# LocationCollection.AsJson方法的具体用法?C# LocationCollection.AsJson怎么用?C# LocationCollection.AsJson使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LocationCollection
的用法示例。
在下文中一共展示了LocationCollection.AsJson方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateMapScriptCore
/// <summary>
/// Registers the JavaScript to display the map.
/// </summary>
/// <param name="scriptManager">The page's script manager.</param>
/// <param name="mapType">Type of the map.</param>
/// <param name="mapSectionId">The ID of the section (div) on the page in which the map should be created.</param>
/// <param name="currentLocationSpanId">The ID of the span showing the current location text.</param>
/// <param name="noLocationSpanId">The ID of the span shown when no location is selected.</param>
/// <param name="instructionSpanId">The ID of the span with driving directions, etc.</param>
/// <param name="directionsLinkId">The ID of the link to driving directions.</param>
/// <param name="directionsSectionId">The ID of the section (div) with driving directions text.</param>
/// <param name="locations">The list of locations to display.</param>
/// <param name="showAllLocationsOnLoad">if set to <c>true</c> shows the map with all locations on it by default.</param>
public override void GenerateMapScriptCore(ScriptManager scriptManager, MapType mapType, string mapSectionId, string currentLocationSpanId, string noLocationSpanId, string instructionSpanId, string directionsLinkId, string directionsSectionId, LocationCollection locations, bool showAllLocationsOnLoad)
{
ICollection<JavaScript.Location> locationsAsJson = locations.AsJson();
string mapParameters = String.Format(CultureInfo.InvariantCulture, "currentLocationSpan: {0}, noLocationSpan: {1}, instructionSpan: {2}, directionsLink: {3}, directionsSection: {4}, mapType: {5}, locationsArray: {6}", GetElementJavaScript(currentLocationSpanId), GetElementJavaScript(noLocationSpanId), GetElementJavaScript(instructionSpanId), GetElementJavaScript(directionsLinkId), GetElementJavaScript(directionsSectionId), ConvertMapType(mapType), new JavaScriptSerializer().Serialize(locationsAsJson));
scriptManager.Scripts.Add(new ScriptReference(GetLoaderUrl(this.ApiKey)));
scriptManager.Scripts.Add(new ScriptReference("Engage.Dnn.Locator.JavaScript.BaseLocator.js", "EngageLocator"));
scriptManager.Scripts.Add(new ScriptReference("Engage.Dnn.Locator.JavaScript.GoogleLocator.js", "EngageLocator"));
ScriptManager.RegisterStartupScript(
scriptManager.Page,
typeof(GoogleProvider),
"Initialize",
"google.setOnLoadCallback(jQuery(function(){ jQuery.noConflict(); $create(Engage.Dnn.Locator.GoogleMap, {" + mapParameters + "}, {}, {}, $get('" + mapSectionId + "')); }));",
true);
if (showAllLocationsOnLoad)
{
ScriptManager.RegisterStartupScript(
scriptManager.Page,
typeof(GoogleProvider),
"showAllLocations",
"google.setOnLoadCallback(jQuery(function(){ $find('" + mapSectionId + "$GoogleMap').showAllLocations(); }));",
true);
}
}