Google Maps, array + GLatLng + GPolyline

I am using the following code to group and show a list of ship positions on a map: function configure_ship_polylines() { var shipPoints = new Array(); // Group positions by ship for (var ScenarioPositionID in __data['scenarioPositions']) { var scenarioPosition = __data['scenarioPositions'][ScenarioPositionID]; var key = "ShipID_" + scenarioPosition.ShipID; // Initialize if necessary if (shipPoints[key] == null) { shipPoints[key] = new Array(); } var latLong = new GLatLng(scenarioPosition.Latitude, scenarioPosition.Longitude); // Append coordinates shipPoints[key].push(latLong); } // Loop through the grouped coordinates and add to map for (var key in shipPoints) { var points = shipPoints[key]; var ShipID = key.substring(7); // Only add polygons with points.length > 1 if (points.length > 1) { var shipPolyline = new GPolyline(points); //alert("Adding polyline: " + shipPolyline + " for ship: " + ShipID + " " + points + " " + typeof points); __mapItems['shipPolylines'][key] = shipPolyline; __map.addOverlay(shipPolyline); } } } What happens is that only *one* of the polylines are displayed on the map. The rest are invisible or aren't added at all (I'm not quite sure how to debug google maps to find out). I have used firebug extensively over and over again to debug this, but everything seems fine. If I create polylines manually I can add them to the map and everything works fine. If I create markers on each point instead of polylines then the markers display fine at the correct places. I'm getting kinda pissed at this because I have almost spent a full work day trying to figure out what the hell is going on. Any ideas?

以上就是Google Maps, array + GLatLng + GPolyline的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准