private string ConfigureMap(MapContext context) { var builder = new StringBuilder(); builder.AppendLine($@"<script type=""text/javascript""> ymaps.ready(init); function init() {{ var myMap = new ymaps.Map(""map"", {{ center: [" + $@"{ConvertToString(context.InitialPoint.Latitude)}, " + $@"{ConvertToString(context.InitialPoint.Longitude)}], zoom: {ConvertToString(context.Zoom)} }});"); foreach (var point in context.RecyclingPoints) { builder.AppendLine( $@"myMap.geoObjects.add(new ymaps.Placemark([" + $@"{ConvertToString(point.GeoCoordinate.Latitude)}, " + $@"{ConvertToString(point.GeoCoordinate.Longitude)}], {{ iconCaption: '{point.Name}' }}));"); } builder.AppendLine(@"} </script>"); return(builder.ToString()); }
public Map GetMap(MapContext context) { var apiKey = configuration[apiKeySetting]; var mapRenderingScript = RenderMap(apiKey); var mapConfigurationScript = ConfigureMap(context); return(new Map { MapRenderingScript = mapRenderingScript, MapConfigurationScript = mapConfigurationScript }); }
public Map GetMap(MapContext context) { context.RecyclingPoints = recyclingPointProvider .GetRecyclingPoints() .Select(point => { // var receivedInfo = mapApiClient.GetInfo(point); // return MergeRecyclingPointInfo(point, receivedInfo); return(point); }) .Where(point => point.GeoCoordinate != null) .ToList(); return(mapApiClient.GetMap(context)); }