Getting the coordinates of marker in Bing Map from Controller with Model

Hi,

By looking at your documentation, I was able to view my markers on the map with Bing Map provider. However, I want to do the same with the coordinate information of the markers by returning the Model from the Controller. How can I do it?

Thanks,



@{

    var data = new[]

    {

            new {latitude= 39.2447, longitude= -77.2539, city= "Baltimore" },

            new {latitude= 39.6184, longitude= -76.6616, city= "Baltimore" },

            new {latitude= 40.5716, longitude= -76.9667, city= "Baltimore" }

    };

    var marker = new List<MapsMarker>

    {

        new MapsMarker{Visible=true, DataSource=data, Width = 30, Height = 30}

    };


    var zoom = new Syncfusion.EJ2.Maps.MapsZoomSettings

    {

        Enable = true,

        ZoomFactor = 7,

        MaxZoom = 20

    };

    var centerPosition = new Syncfusion.EJ2.Maps.MapsCenterPosition

    {

        Latitude = 40.047095,

        Longitude = -77.901296

    };


}


@using Syncfusion.EJ2.Maps;

@using Syncfusion.EJ2;

<div id="control-section">

    <ejs-maps id="maps" height="800px" zoomSettings="zoom" centerPosition="centerPosition">

        <e-maps-layers>

            <e-maps-layer layerType="Bing" bingMapType="CanvasLight" markerSettings="marker" key="{bingmapkey}"></e-maps-layer>

        </e-maps-layers>

    </ejs-maps>

</div>



5 Replies 1 reply marked as answer

IR Indumathi Ravi Syncfusion Team February 25, 2022 02:25 PM UTC

Hi John, 

Thank you for contacting Syncfusion support. 

We can meet your requirements by creating a "MarkerModel.cs" model class file and sending it to the view via the "ViewBag.MarkerData" by creating a list of markers using the class fields in the "HomeController.cs". Please see the attached code snippet. 
 
Code Snippet: 
[HomeController.cs] 

public IActionResult Index() 
    List<MarkerModel> marker = new List<MarkerModel>(); 
    MarkerModel markerone = new MarkerModel(); 
    markerone.Latitude = 39.2447; 
    markerone.Longitude = -77.2539; 
    markerone.City = "Baltimore"; 
    marker.Add(markerone); 

    //.. 
    //.. 

    ViewBag.MarkerData = marker; 
    return View(); 

[Index.cshtml] 

@{ 
     var marker = new List<MapsMarker> 
    { 
        new MapsMarker{Visible=true, DataSource= ViewBag.MarkerData, Width = 30, Height = 30} 
    }; 
}  

[MarkerModel.cs] 

public class MarkerModel 
    public double Latitude { get; set; } 
    public double Longitude { get; set; } 
    public string City { get; set; } 

We have created a sample to demonstrate the same and it can be downloaded from the below link. 
 
Please let us know if the above sample meet your requirement. 

Regards, 
Indumathi R.


JT John Taylor March 2, 2022 12:53 AM UTC

Thanks it works. I have one more question. As you mentioned, I take the coordinates and show them as markers on the map. However, the number of markers in a certain area is high. For this reason, I use Marker clustering. I did it as you described in your documentation, but when using marker clustering, the markers load very late, especially when zooming, sometimes it cannot load, the page remains blank. When the number of markers is high in a certain area, when marker clustering is not used, it loads slowly, but it is faster than clustering. Is there any method you can suggest for this problem?




Attachment: bingMap_markers_fa74634c.rar


IR Indumathi Ravi Syncfusion Team March 2, 2022 01:47 PM UTC

Hi John, 

Thank you for the update. 

We are currently analyzing the reported scenario in the Maps component. We will update you with further details on March 3, 2022. 

Regards, 
Indumathi R


JT John Taylor March 4, 2022 04:41 PM UTC

Hi,


Is there any development on the subject?




SA Sabari Anand Senthamarai Kannan Syncfusion Team March 7, 2022 11:47 AM UTC

Hi John, 

Sorry for the delay. 

We rendered 4000 markers in the Maps control with Bing Maps and discovered that rendering with marker clusters takes approximately 6 to 8 seconds. This is due to the large number of markers and also to generate clusters for marker clustering, in which we will compare each marker to other markers (in the source code). As a result, rendering the marker clusters in the control takes some time. This is also the case with the zooming operation. This is the behavior of the Maps control. Please find the screen capture video below for your reference. 

We are unable to reproduce the reported performance lags such as "page remains blank" and "markers and clusters loading very late" in the Maps control. If you are still facing the reported scenarios, please provide us the sample application to reproduce the reported scenarios. It will be helpful for us to analyze and assist you further. 

Regards, 
Sabari Anand.

Marked as answer
Loader.
Up arrow icon