javascript – 如何在没有错误的情况下在bingmaps中推送2044个zipcodes表达式太长或太复杂而无法编译?

我试图在bingmaps中制作所有荷兰(4044)拉链码的多边形.每个邮政编码都有10到1000个坐标.我尝试了以下代码,它适用于大约200个zipcode:

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);

我也尝试过这个,这是我喜欢看到的:

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);

}

两者都使用有限的zipcodes.但是当我试图用~200坐标推出更多~300个邮政编码/多边形时,它会返回下面的错误.我正在使用带有bingmaps的visual studio .net.有谁知道如何解决这个错误?或者可能是另一个显示所有荷兰拉链码的解决方案?
‘/’应用程序中的服务器错误.

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

最佳答案 之前没见过那个错误.看起来像ASP.NET中的东西.在任何情况下,尝试渲染4044邮政编码多边形,每个200坐标都不起作用.这只是JavaScript要处理的太多数据.这将创建大量的DOM对象,并且每次地图移动时也会重新投射大量数据.它对于用户来说也是一个相当大的下载(猜测大小超过9MB).

也就是说,可以使用正确的架构在Bing地图上显示数百万个多边形.诀窍是将您的数据转换为图块(图像堆).这样浏览器一次只需处理几张图像.这显着减少了用户必须下载的数据量.这是我制作的一个演示,它渲染了175,000个多边形,每个多边形有200个坐标:http://onsbingmapsdemo.cloudapp.net/在此示例中,将图钉拖到多边形上以检索有关它的一些信息.我可以选择只使用鼠标点击,但我想在这个应用程序中尝试不同的东西.

有几种方法可以生成这些切片图层.这里有一个开源MVC应用程序:http://ajaxmapdataconnector.codeplex.com/

我还有一份尚未发布的白皮书,介绍了如何执行此操作.如果您通过Hotmail.com向ricky_brundritt发送电子邮件,我会向您发送一份论文和代码示例.

点赞