-1
航空路線と空港の配列をループするコードがあり、各空港にマーカーを配置し、それらの間にポリラインを描画します。コードは機能し、400ルートがあるときは問題ありません。私がそれを完全な〜3500ishのルートに展開すると、ほぼ1分のレンダリングのために停止します。私はこれをスピードアップできる方法はありますか?複数のgmapポリラインを迅速にレンダリングする方法
map.fitBounds(bounds);
var flightPath;
var flightPlanCoordinates;
$.each(routes, function(key, route) {
flightPlanCoordinates = [];
flightPlanCoordinates.push(markers[route.origincode].position);
flightPlanCoordinates.push(markers[route.destinationcode].position);
flightPath = new google.maps.Polyline({
path: flightPlanCoordinates,
geodesic: true,
strokeColor: '#004494',
strokeOpacity: 0.2,
strokeWeight: 1
});
flightPath.setMap(map); //commenting this line speeds things back up
google.maps.event.addListener(flightPath, 'mouseover', function (event) {
this.setOptions({
strokeOpacity: 1,
strokeWeight: 2
});
});
google.maps.event.addListener(flightPath, 'mouseout', function (event) {
this.setOptions({
strokeOpacity: 0.2,
strokeWeight: 1
});
});
});
あなたが何を意味するのかよく分かりません。 –
やsetListenerをユーザの操作に使うことができ、直ちにすべてのルートをレンダリングするのではなく、必要なときにUIをレンダリングするので、UIの変更はUIスレッドにとって大きな課題になります。 –
UIのスレッドでしかUIを変更できないので、大きなデータが出たときに速度を上げたい場合は、配列の代わりにストリーミング日付を使用する必要があります。 –