3

I am unable to find the exact solution for a browser crash in rendering multiple polygons on map in my application when using up to 500 polygons and have 14000 lat/long associated. It loads fine for up to 300 polygons, then after that the browser crashes due to ram utilization increasing and CPU performance dropping.

Is there any solution for this so that RAM and CPU utilization be less, so you can run the application without crashing the browser?

function init(mydata){

    var mypolygons  = [];
    var bounds      = new google.maps.LatLngBounds();
    for (i = 0; i < mydata.length; i++){        
        var placemark_name = mydata[i].placemark_name ; 
        var latlong = mydata[i].latlong;
        LatLng = [];
            for (j = 0; j < latlong.length; j++) {

                var lat = latlong[j].LatitudeLongitude.latitude;
                var lng = latlong[j].LatitudeLongitude.longitude;

                LatLng.push(new google.maps.LatLng(lat,lng));
                bounds.extend(LatLng[LatLng.length-1]);
                map.fitBounds(bounds);
            }

            var polygonOptions = {
                paths:LatLng,
                strokeColor: '#FF0000',
                fillColor: '#FF0000',
                draggable: false,
                editable:true,
                fillOpacity: 0.35,
                strokeOpacity: 0.8
            };  

            mypolygons.push(new google.maps.Polygon(polygonOptions));
            mypolygons[i].setMap(map);                              
    }           
}
sampathsris
  • 21,564
  • 12
  • 71
  • 98
  • 1
    [FusionTablesLayer](https://developers.google.com/maps/documentation/javascript/fusiontableslayer) may be an option – Dr.Molle Apr 25 '15 at 07:57
  • Or any other layer based rendering solution, like [KmlLayer](https://developers.google.com/maps/documentation/javascript/kmllayer) or a server based solution. – geocodezip Apr 25 '15 at 12:26
  • 1
    Thanks for our suggestions and links.Finally i found the solution and that was to keep the property "editable:true" to "editable:false" and everything worked fine. – Mukesh Kumar Apr 27 '15 at 15:42
  • @AbhimanyuKumar: You may want to consider posting your solution as an answer. See [Can I answer my own question?](http://stackoverflow.com/help/self-answer). – sampathsris Apr 28 '15 at 05:39

1 Answers1

0
I found the solution and that was to keep the property 
"editable:true" to "editable:false" and 
Everything worked fine.