Home > web development > KML on Bing Maps: Beyond the 200-item Limit

KML on Bing Maps: Beyond the 200-item Limit

imageIn importing KML into a Bing Maps (nee MS Virtual Earth) map, you will run into a limit of how many items or shapes it will allow you to render. 

The reason for this is performance, as it’s generally understood that one will start getting degraded performance as you go up over 200 shapes being put on the map at any one time.  Well, I did indeed experience such in IE8, but not in Safari, Chrome or Firefox – so, many of us may want/need to put more than their default 200 shapes on the screen.

To do this, you use the MaxImportedShapes property of the VEShapeSourceSpecification class (defined here), done something like this:

 

<script type="text/javascript" src="http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6"></script>
<script type="text/javascript">
    var map = null;

    function EventMapLoad() {
        var shapeLayer = new VEShapeLayer();
        // var shapeLimit = new VEShapeSourceSpecification.MaxImportedShapes = 500;
        var shapeSpec = new VEShapeSourceSpecification(VEDataType.ImportXML,
http://myhost.com/myKmlFile.kml, shapeLayer);
        shapeSpec.MaxImportedShapes = 500;
        map.ImportShapeLayerData(shapeSpec);
    }

    function CreateMap() {
        map = new VEMap(’myMap’);
        map.onLoadMap = EventMapLoad;
        map.LoadMap(null, 3, VEMapStyle.Hybrid);
    }
</script>

This will set the maximum number of shapes to 500.  I haven’t tested with much more than that, so performance will almost certainly be intolerable if you kick that up to 1000 shapes plus. 

This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.

  1. No comments yet.
  1. No trackbacks yet.