Search results

Print and Export

Print

The rendered map can be printed directly from the browser by calling the public method print. ID of the map div element must be passed as argument to that method.

razor
print.cs
@using Syncfusion.EJ2;
@Html.EJS().Button("togglebtn").IconCss("e-icons e-play-icon").Content("Print").CssClass("e-flat").Render()
@Html.EJS().Maps("maps").Height("450px").Width("650px").Layers(new List<Syncfusion.EJ2.Maps.MapsLayer>{
       new Syncfusion.EJ2.Maps.MapsLayer
       {
           ShapeData = ViewBag.ShapeData,

           TooltipSettings = new MapsTooltipSettings
           {
               Visible = true, ValuePath = "name",
           },
            ShapeSettings = new MapsShapeSettings
           {
                Autofill = true,

           },
            DataLabelSettings = new MapsDataLabelSettings
            {
                Visible = true,
                LabelPath = "name",
                SmartLabelMode =  SmartLabelMode.Trim,
            }
       }
}).Render()

<script>
    document.getElementById('togglebtn').onclick = function () {
        var map = document.getElementById('maps').ej2_instances[0];
        map.print();
    };
</script>
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using EJ2_Core_Application.Models;
using Newtonsoft.Json;

namespace EJ2_Core_Application.Controllers
{
    public class HomeController : Controller
    {
        public IActionResult Index()
        {
            ViewBag.shapeData = getusMap();
            return View();
        }        
    }
}

Export

The rendered map can be exported to jpeg or png format by using export method in map. Input parameters for this method are Export Type for format and fileName of result.

razor
export.cs
@using Syncfusion.EJ2;
@Html.EJS().Button("togglebtn").IconCss("e-icons e-play-icon").Content("Export").CssClass("e-flat").Render()
@Html.EJS().Maps("maps").Height("450px").Width("650px").Layers(new List<Syncfusion.EJ2.Maps.MapsLayer>{
       new Syncfusion.EJ2.Maps.MapsLayer
       {
           ShapeData = ViewBag.ShapeData,
           MarkerSettings = new List<Syncfusion.EJ2.Maps.MapsMarker>
           {
               new Syncfusion.EJ2.Maps.MapsMarker
               {
                   Visible = true, Height = 20,Width = 15, Shape = Syncfusion.EJ2.Maps.MarkerType.Balloon,
                   Fill = "#E13E40", AnimationDuration = 0, DataSource = markerData,
                   TooltipSettings = new MapsTooltipSettings{ Visible = true, ValuePath = "name" }

               },
           }
        }
}).Render()

<script>
    document.getElementById('togglebtn').onclick = function () {
        var map = document.getElementById('maps').ej2_instances[0];
        map.export('PNG', 'Export');
    };
</script>
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using EJ2_Core_Application.Models;
using Newtonsoft.Json;

namespace EJ2_Core_Application.Controllers
{
    public class HomeController : Controller
    {
        public IActionResult Index()
        {
            ViewBag.shapeData = this.WorldMap();
            ViewBag.dataSource = this.getUNOData();
            return View();
        }        
    }
}
Contents
Contents