4
votes

I am trying to make polygons of all dutch (4044)zipcodes in bingmaps. Each zipcode has 10 to 1000 coordinates. I tried the following code and it works with about 200 zipcodes:

var polygoncolor = new Microsoft.Maps.Color(100, 255, 0, 0);
var  pc1011 = new Array (
new Microsoft.Maps.Location(52.372203,4.913825),
new Microsoft.Maps.Location(52.375787,4.912745),
new Microsoft.Maps.Location(52.37605,4.911752));         
var polygon1011 = new Microsoft.Maps.Polygon(pc1011  , {
            fillColor: polygoncolor,
            strokeColor: polygoncolor
        });
map.entities.push(polygon1011);

I have also tried this, this is what I love to see it work:

var myMappings = [
{  pc: "1011", coor: new Array(
     new Microsoft.Maps.Location(52.365669,4.901578),
     new Microsoft.Maps.Location(52.372203,4.913825),
     new Microsoft.Maps.Location(52.378387,4.905391)
)},
  {     
    pc: "1012", coor: new Array(
    new Microsoft.Maps.Location(52.381136,4.89783),
    new Microsoft.Maps.Location(52.372203,4.913825),
    new Microsoft.Maps.Location(52.382393,4.900011)
)}];

for (var i = 0; i < myMappings.length; i += 1) {
     var polygoncolor = new Microsoft.Maps.Color(100, 0, 0, 100);
     var polygon = new Microsoft.Maps.Polygon(myMappings[i].coor, {
       fillColor: polygoncolor,
       strokeColor: polygoncolor
     });
     map.entities.push(polygon);

}

Both works with limited zipcodes. But when I tried to push more then ~300 zipcode/polygons with ~200 coordinates it wil return me the error below. I’m using visual studio .net with bingmaps. Does anybody know how to fix this error? Or maybe a whole other solution to show all dutch zipcodes? Server Error in '/' Application.

Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS1647: An expression is too long or complex to compile

Source Error:

[No relevant source lines]

Source File: Line: 0

Show Detailed Compiler Output:

C:\Program Files (x86)\IIS Express> "C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe" /t:library /utf8output /R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\f424c542\388c287e\assembly\dl3\5c6e370b\4d00bf6a_4fbad001\Owin.dll" /R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\f424c542\388c287e\assembly\dl3\7681319b\0974f36a_4fbad001\Microsoft.Owin.Security.Facebook.dll" /R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\f424c542\388c287e\assembly\dl3\3da77e53\b169fadb_6ebdd001\Newtonsoft.Json.dll" /R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\f424c542\388c287e\assembly\dl3\bd686e79\7b2fc066_4fbad001\System.Web.Optimization.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Activation\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Activation.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.DynamicData\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.DynamicData.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Activities\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Activities.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.CSharp\v4.0_4.0.0.0__b03f5f7f11d50a3a\Microsoft.CSharp.dll" /R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\f424c542\388c287e\assembly\dl3\f842014c\0fecca6a_4fbad001\Microsoft.Owin.dll" /R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\f424c542\388c287e\assembly\dl3\6f59fdc9\8d4b0b6b_4fbad001\Microsoft.Owin.Security.OAuth.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.WebPages.Deployment\v4.0_2.0.0.0__31bf3856ad364e35\System.Web.WebPages.Deployment.dll" /R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\f424c542\388c287e\assembly\dl3\56402444\297ced66_4fbad001\System.Web.Helpers.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.Extensions\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.Extensions.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Data.DataSetExtensions\v4.0_4.0.0.0__b77a5c561934e089\System.Data.DataSetExtensions.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Activities\v4.0_4.0.0.0__31bf3856ad364e35\System.Activities.dll" /R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\f424c542\388c287e\assembly\dl3\8f6cdbf0\c5e7276b_4fbad001\Microsoft.Owin.Security.Twitter.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.VisualStudio.Web.PageInspector.Loader\v4.0_1.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.Web.PageInspector.Loader.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll" /R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\f424c542\388c287e\assembly\dl3\103b82c7\dd40f266_4fbad001\System.Web.WebPages.Razor.dll" /R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\f424c542\388c287e\assembly\dl3\b4762c60\e1aea267_4fbad001\Antlr3.Runtime.dll" /R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\f424c542\388c287e\assembly\dl3\cd282b56\31b2b06a_4fbad001\Microsoft.AspNet.Identity.EntityFramework.dll" /R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\f424c542\388c287e\assembly\dl3\203e57f7\3b98386b_4fbad001\Microsoft.Owin.Security.MicrosoftAccount.dll" /R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\f424c542\388c287e\assembly\dl3\255a589c\619f9d6a_4fbad001\Microsoft.AspNet.Identity.Owin.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.WorkflowServices\v4.0_4.0.0.0__31bf3856ad364e35\System.WorkflowServices.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.ApplicationServices\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.ApplicationServices.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.IdentityModel\v4.0_4.0.0.0__b77a5c561934e089\System.IdentityModel.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel\v4.0_4.0.0.0__b77a5c561934e089\System.ServiceModel.dll" /R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\f424c542\388c287e\assembly\dl3\c3f526d4\ebee8c6a_4fbad001\Microsoft.AspNet.Identity.Core.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll" /R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\f424c542\388c287e\assembly\dl3\6edcd541\3d3ce677_c4c3d001\maps.dll" /R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\f424c542\388c287e\assembly\dl3\6e7a6b7d\adad6769_4fbad001\EntityFramework.SqlServer.dll" /R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\f424c542\388c287e\assembly\dl3\0503b2c1\4f37176b_4fbad001\Microsoft.Owin.Security.Google.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml.Linq\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.Linq.dll" /R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\f424c542\388c287e\assembly\dl3\c63f78a4\77ee4067_4fbad001\System.Web.Mvc.dll" /R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\f424c542\388c287e\assembly\dl3\cc81fdfe\83deef66_4fbad001\System.Web.WebPages.Deployment.dll" /R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\f424c542\388c287e\App_global.asax.etzehoqu.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_32\System.Web\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Web.dll" /R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\f424c542\388c287e\assembly\dl3\110d2b98\cb5fff6a_4fbad001\Microsoft.Owin.Security.Cookies.dll" /R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\f424c542\388c287e\assembly\dl3\53ac7b7e\2772c667_4fbad001\WebGrease.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Runtime.Serialization\v4.0_4.0.0.0__b77a5c561934e089\System.Runtime.Serialization.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.WebPages.Deployment\v4.0_1.0.0.0__31bf3856ad364e35\System.Web.WebPages.Deployment.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_32\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll" /R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll" /R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\f424c542\388c287e\assembly\dl3\76481f41\adad6769_4fbad001\EntityFramework.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.Web.Infrastructure\v4.0_1.0.0.0__31bf3856ad364e35\Microsoft.Web.Infrastructure.dll" /R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\f424c542\388c287e\assembly\dl3\efc86ab6\356c9c66_4fbad001\System.Web.Razor.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ComponentModel.DataAnnotations\v4.0_4.0.0.0__31bf3856ad364e35\System.ComponentModel.DataAnnotations.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Web\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Web.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_32\System.EnterpriseServices\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.dll" /R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\f424c542\388c287e\assembly\dl3\0a93f772\4788e76a_4fbad001\Microsoft.Owin.Security.dll" /R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\f424c542\388c287e\assembly\dl3\72fa3533\2b3ad96a_4fbad001\Microsoft.Owin.Host.SystemWeb.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.Services\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Web.Services.dll" /R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\f424c542\388c287e\assembly\dl3\031deb56\dd40f266_4fbad001\System.Web.WebPages.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll" /out:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\f424c542\388c287e\App_Web_index.cshtml.a8d08dba._pu9obdf.dll" /D:DEBUG /debug+ /optimize- /w:4 /nowarn:1659;1699;1701;612;618 /warnaserror- "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\f424c542\388c287e\App_Web_index.cshtml.a8d08dba._pu9obdf.0.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\f424c542\388c287e\App_Web_index.cshtml.a8d08dba._pu9obdf.1.cs"

Microsoft (R) Visual C# Compiler version 4.0.30319.18408

for Microsoft (R) .NET Framework 4.5 Copyright (C) Microsoft Corporation. All rights reserved.

fatal error CS1647: An expression is too long or complex to compile

1

1 Answers

2
votes

Haven't seen that error before. Looks like something in ASP.NET. In any case trying to render 4044 zip code polygons with 200 coordinates each won't work. That's simply too much data for JavaScript to handle. That would create a lot of DOM objects and is also a ton of data to reproject every time the map moves. It would also be a fairly large download for the user (guessing more than 9MB in size).

That said it is possible to visualize millions of polygons on Bing Maps with the right architecture. The trick is to turn your data into tiles (bunch of images). This way the browser only has to handle a few images at a time. This significantly reduce the amount of data the user would have to download. Here is a demo I made that rendered 175,000 polygons that have upwards of 200 coordinates each: http://onsbingmapsdemo.cloudapp.net/ In this sample, drag the pushpin over a polygon to retrieve some info about it. I could have alternatively just used a mouse click, but I wanted to try something different in this app.

There are a couple ways to generate these tile layers. There is an open source MVC app here: http://ajaxmapdataconnector.codeplex.com/

I also have a white paper that isn't yet published that goes through how to do this. If you email me at ricky_brundritt at Hotmail.com, I'll send you a copy of the paper and code samples.