简体   繁体   中英

How can i load a big amount of data to Gmaps

I already searched for recent questions about this but none are useful, my problem is that i have a.csv file with more than 1000 locations and i need to load and show them using Gmaps and c# but it just freezes and stops working, ¿is there any way i can do this and load all the locations?

public void loadLocations()
{
    mapa.MapProvider = GMapProviders.BingMap;
    mapa.Position = new PointLatLng(69.5603, -144.3315);
    mapa.MinZoom = 2;
    mapa.MaxZoom = 24;
    mapa.Zoom = 5;
    Size siz = new System.Drawing.Size(700, 500);
    mapa.DragButton = MouseButtons.Left;
    mapa.ClientSize = siz;
    gMapOverlay = new GMap.NET.WindowsForms.GMapOverlay("markers");
    gMapOverlay.IsVisibile = true;


    for (var i = 0; i < u.Count; i++)
    {
        double la = u[i].altitude1;//it  just get the coordinates from the array
        double lon = u[i].longitude1;
        var marker = new GMarkerGoogle(new PointLatLng(la, lon), GMarkerGoogleType.orange_dot);

        marker.IsVisible = true;

        gMapOverlay.Markers.Add(marker);

        mapa.Overlays.Add(gMapOverlay);

    }

}

Instead of adding u.Count new overlays (which freezes your map), create a single overlay containing all your markers:

for (var i = 0; i < u.Count; i++)
{
    double la = u[i].altitude1;//it  just get the coordinates from the array
    double lon = u[i].longitude1;
    var marker = new GMarkerGoogle(new PointLatLng(la, lon), GMarkerGoogleType.orange_dot);
    marker.IsVisible = true;
    gMapOverlay.Markers.Add(marker);
}
mapa.Overlays.Add(gMapOverlay);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM