예제 #1
0
        /// <summary>
        /// Notifies change.
        /// </summary>
        public void TriggerRendering(bool force)
        {
            // notify map layout of changes.
            if (this.Width > 0 && this.Height > 0)
            {
                // create the view.
                View2D view = _renderer.Create(this.Width, this.Height,
                                               this.Map, (float)this.Map.Projection.ToZoomFactor(this.MapZoom),
                                               this.MapCenter, false, true);

                // notify the map that the view has changed.
                this.Map.ViewChanged((float)this.Map.Projection.ToZoomFactor(this.MapZoom), this.MapCenter,
                                     view);

                _mapView.NotifyMapChange(this.Width, this.Height, view, this.Map.Projection);

                this.SetOrtho(view);

                // build the layers list.
                var layers = new List <Layer>();
                for (int layerIdx = 0; layerIdx < this.Map.LayerCount; layerIdx++)
                {
                    // get the layer.
                    layers.Add(this.Map[layerIdx]);
                }

                _renderer.Render(_target,
                                 layers,
                                 view,
                                 (float)this.Map.Projection.ToZoomFactor(this.MapZoom));
            }
        }
예제 #2
0
        /// <summary>
        /// Raises the draw event.
        /// </summary>
        /// <param name="canvas">Canvas.</param>
        protected override void OnDraw(global::Android.Graphics.Canvas canvas)
        {
            try
            {
                base.OnDraw(canvas);

                if (_renderingSuspended)
                { // do nothing when rendering is suspended.
                    return;
                }

                // set the height/width.
                if (_surfaceHeight != canvas.Height ||
                    _surfaceWidth != canvas.Width)
                {
                    _surfaceHeight = canvas.Height;
                    _surfaceWidth  = canvas.Width;

                    // make sure markers are in the correct position too.
                    _mapView.NotifyMapChange(this.SurfaceWidth, this.SurfaceHeight, this.CreateView(), this.Map.Projection);

                    // trigger rendering.
                    this.TriggerRendering();

                    // raise map initialized.
                    _mapView.RaiseMapInitialized();
                }

                if (_onScreenBuffer != null)
                { // there is a buffer.
                    // render only the cached scene.
                    canvas.DrawColor(new global::Android.Graphics.Color(_backgroundColor));
                    View2D view       = this.CreateView();
                    float  zoomFactor = (float)this.Map.Projection.ToZoomFactor(this.MapZoom);
                    _renderer.SceneRenderer.Render(
                        canvas,
                        view,
                        zoomFactor,
                        new Primitive2D[] { _onScreenBuffer });
                }
            }
            catch (Exception ex)
            {
                OsmSharp.Logging.Log.TraceEvent("MapViewSurface", TraceEventType.Critical,
                                                string.Format("An unhandled exception occured:{0}", ex.ToString()));
            }
        }
예제 #3
0
        /// <summary>
        /// Notifies that there was movement.
        /// </summary>
        private void NotifyMovement()
        {
            // invalidate the current view.
            this.Invalidate();

            // notify map layout of changes.
            if (this.Width > 0 && this.Height > 0)
            {
                View2D view = _cacheRenderer.Create(this.Width, this.Height,
                                                    this.Map, (float)this.Map.Projection.ToZoomFactor(this.MapZoomLevel),
                                                    this.MapCenter, _invertX, _invertY);
                _mapLayout.NotifyMapChange(this.Width, this.Height, view, this.Map.Projection);
            }
        }
예제 #4
0
        /// <summary>
        /// Notifies that there was movement.
        /// </summary>
        private void NotifyMovement()
        {
            // invalidate the current view.
            this.Invalidate();

            // notify map layout of changes.
            if (this.SurfaceWidth > 0 && this.SurfaceHeight > 0)
            {
                // create the current view.
                View2D view = this.CreateView();

                // notify map change to reposition markers.
                _mapView.NotifyMapChange(this.SurfaceWidth, this.SurfaceHeight, view, this.Map.Projection);

                // notify listener.
                _listener.NotifyChange(view, this.MapZoom);
            }
        }