public OnlineMapsBuffer(OnlineMaps map) { this.map = map; lastState = new StateProps { floatZoom = map.floatZoom, width = map.width, height = map.height }; map.GetPosition(out lastState.longitude, out lastState.latitude); map.GetCorners(out lastState.leftLongitude, out lastState.topLatitude, out lastState.rightLongitude, out lastState.bottomLatitude); renderState = lastState; newTiles = new List <OnlineMapsTile>(); }
public void GenerateFrontBuffer() { try { lastState = new StateProps { floatZoom = map.floatZoom, width = map.width, height = map.height }; map.GetPosition(out lastState.longitude, out lastState.latitude); map.GetCorners(out lastState.leftLongitude, out lastState.topLatitude, out lastState.rightLongitude, out lastState.bottomLatitude); while (!disposed) { #if !UNITY_WEBGL while (status != OnlineMapsBufferStatus.start && map.renderInThread) { if (disposed) { return; } OnlineMapsUtils.ThreadSleep(1); } #endif status = OnlineMapsBufferStatus.working; renderState = new StateProps { floatZoom = map.floatZoom, width = map.width, height = map.height }; try { map.GetPosition(out renderState.longitude, out renderState.latitude); map.GetCorners(out renderState.leftLongitude, out renderState.topLatitude, out renderState.rightLongitude, out renderState.bottomLatitude); if (newTiles != null && map.control.resultIsTexture) { ApplyNewTiles(); } if (disposed) { return; } UpdateBackBuffer(renderState.longitude, renderState.latitude, renderState.zoom); if (disposed) { return; } if (map.control.resultIsTexture) { GetFrontBufferPosition(renderState.longitude, renderState.latitude, bufferPosition, renderState.floatZoom, renderState.width, renderState.height); UpdateFrontBuffer(renderState.width, renderState.height, renderState.floatZoom); if (disposed) { return; } foreach (OnlineMapsDrawingElement element in OnlineMapsDrawingElementManager.instance) { if (disposed) { return; } element.Draw(frontBuffer, new Vector2(bufferPosition.x + (float)frontBufferPosition.x / OnlineMapsUtils.tileSize, bufferPosition.y + (float)frontBufferPosition.y / OnlineMapsUtils.tileSize), renderState.width, renderState.height, renderState.floatZoom); } if (map.control.OnDrawMarkers != null) { map.control.OnDrawMarkers(); } } } catch (Exception exception) { if (disposed) { return; } Debug.Log(exception.Message + "\n" + exception.StackTrace); } status = OnlineMapsBufferStatus.complete; lastState = renderState; #if !UNITY_WEBGL if (!map.renderInThread) { break; } #else break; #endif } } catch { } }