English 中文(简体)
在基于 Googlemap 的标记时间中绘制多边形
原标题:Draw Polygon in Googlemap based marker time

我想通过连接googlemap 中的标记来绘制一个多边形。 时间与每个标记相关。 所以我想要根据时间连接每个点。 如何做到这一点。 目前的代码会这样被插入。 需要更改的地方 。

       var marker = new Array();
       var points = new Array();
     for(var i=0;i<value.length;i++)
          {
               var tempar=value[i].split( , );
               var center = new GLatLng(tempar[0], tempar[1]);
               var mar = new GMarker(center, icon);
               var imgpth=tempar[3]; 
               var tme=tempar[2];
               marker.push(mar);   
               marker[i].time = tempar[2];
               points.push(marker[i].getLatLng());
               drawMarker(mar,imgpth,tme);                   
        }
          for(i=;i<marker.length;i++)
         {
            map.addOverlay(marker[i]);
          }
           var polyline = new GPolygon(points, "#f33f00", 2, 1, "#ff0000", 0.2);
           map.addOverlay(polyline);
最佳回答

最简单的方式是按时间排序 < code> marker 数组。 假设 < code> time 属性有某种合理值( 不是字符串) :

marker.sort(function(a,b){return a.time-b.time});

如果 time 是字符串的话 :

marker.sort(function(a,b) {
 var date1 = new Date(a.time);
 var date2 = new Date(b.time);
 return date1.getTime() - date2.getTime();

});
问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签