Esempio n. 1
0
 public MapViewLayoutParams(Context context, IAttributeSet attrs)
     : base(context, attrs)
 {
     this.X = attrs.GetAttributeIntValue("http://schemas.mapquest.com/apk/res/mapquest", "x", int.MaxValue);
     this.Y = attrs.GetAttributeIntValue("http://schemas.mapquest.com/apk/res/mapquest", "x", int.MaxValue);
     String geoPoint = attrs.GetAttributeValue("http://schemas.mapquest.com/apk/res/mapquest", "geoPoint");
     if ((geoPoint.Length > 0))
     {
         String[] arr = geoPoint.Split(new[] { "," }, StringSplitOptions.None);
         if (arr.Length > 1)
         {
             try
             {
                 double latitude = Double.Parse(arr[0].Trim());
                 double longitude = Double.Parse(arr[1].Trim());
                 this.Point = new GeoPoint(latitude, longitude);
                 this.Mode = 0;
             }
             catch (NumberFormatException nfe)
             {
                 Log.Error("mq.android.maps.mapview", "Invalid value for geoPoint attribute : " + geoPoint);
             }
         }
     }
 }
 public void OnTap(GeoPoint p0, MapView p1)
 {
     int lastTouchedIndex = _overlay.LastFocusedIndex;
     if (lastTouchedIndex > -1)
     {
         var tapped = (OverlayItem)_overlay.GetItem(lastTouchedIndex);
         _annotationView.ShowAnnotationView(tapped);
     }
 }
Esempio n. 3
0
        public BoundingBox Union(BoundingBox bbox)
        {
            var lrX = Math.Min(Lr.Longitude, bbox.Lr.Longitude);
            var lrY = Math.Min(Lr.Latitude, bbox.Lr.Latitude);
            var ulX = Math.Max(Ul.Longitude, bbox.Ul.Longitude);
            var ulY = Math.Max(Ul.Latitude, bbox.Ul.Latitude);

            Lr = new GeoPoint(lrY, lrX);
            Ul = new GeoPoint(ulY, ulX);
            return this;
        }
Esempio n. 4
0
        public static BoundingBox CreateBoundingBoxFromRect1(Rect rect, MapView mapView)
        {
            var projection = mapView.Projection;

            GeoPoint ul = projection.FromPixels(rect.Left, rect.Top);
            GeoPoint ur = projection.FromPixels(rect.Right, rect.Top);
            GeoPoint ll = projection.FromPixels(rect.Left, rect.Bottom);
            GeoPoint lr = projection.FromPixels(rect.Right, rect.Bottom);
            var points = new GeoPoint[4];
            points[0] = ul;
            points[1] = ur;
            points[2] = ll;
            points[3] = lr;

            int l = To1E6(180.0D); int r = To1E6(-180.0D); int t = To1E6(-90.0D); int b = To1E6(90.0D);
            for (int i = 0; i < points.Length; i++)
            {
                if (points[i].LongitudeE6 < l)
                {
                    l = points[i].LongitudeE6;
                }
                if (points[i].LongitudeE6 > r)
                {
                    r = points[i].LongitudeE6;
                }
                if (points[i].LatitudeE6 > t)
                {
                    t = points[i].LatitudeE6;
                }
                if (points[i].LatitudeE6 < b)
                {
                    b = points[i].LatitudeE6;
                }
            }

            var bbox = new BoundingBox(new GeoPoint(t, l), new GeoPoint(b, r));
            return bbox;
        }
Esempio n. 5
0
        protected virtual void DrawLineCore(IGeometry line, Paint linePaint, Rect imageRegion, Rect clipBounds,
                                            BoundingBox screenBox, MapView mapView, Canvas canvas)
        {
            var             projection = mapView.Projection;
            List <GeoPoint> data       = Simplify(mapView, ((LineString)line).Vertices);

            if (Rect.Intersects(imageRegion, clipBounds))
            {
                //long start = System.CurrentTimeMillis();

                _path.Reset();
                Point currentPoint = null;
                Point nextPoint    = null;
                for (int i = 0; i < data.Count; i++)
                {
                    var currentGeoPoint = data[i];
                    if (!screenBox.Contains(currentGeoPoint))
                    {
                        if (i + 1 < data.Count)
                        {
                            currentPoint = projection.ToPixels(currentGeoPoint, currentPoint);
                            var nextGeoPoint = data[i + 1];
                            if (screenBox.Contains(nextGeoPoint))
                            {
                                nextPoint = projection.ToPixels(nextGeoPoint, null);
                                DrawLine(nextPoint, currentPoint);
                            }
                        }
                    }
                    else
                    {
                        currentPoint = projection.ToPixels(currentGeoPoint, currentPoint);
                        if (ShowPoints)
                        {
                            if (PointPaint == null)
                            {
                                PointPaint = CreatePointPaint();
                            }
                            canvas.DrawCircle(currentPoint.X, currentPoint.Y, PointPaint.StrokeWidth, PointPaint);
                        }
                        GeoPoint nextGeoPoint = null;
                        if (data.Count > i + 1)
                        {
                            nextGeoPoint = (GeoPoint)data[i + 1];
                        }
                        if (nextGeoPoint != null)
                        {
                            nextPoint = projection.ToPixels(nextGeoPoint, null);
                            DrawLine(currentPoint, nextPoint);
                        }
                    }
                }
                if (_path.IsEmpty)
                {
                    for (int i = 0; i < data.Count; i++)
                    {
                        GeoPoint currentGeoPoint = data[i];

                        GeoPoint nextGeoPoint = null;
                        if (data.Count > i + 1)
                        {
                            nextGeoPoint = data[i + 1];
                        }
                        if (nextGeoPoint != null)
                        {
                            currentPoint = projection.ToPixels(currentGeoPoint, null);
                            nextPoint    = projection.ToPixels(nextGeoPoint, null);
                            DrawLine(currentPoint, nextPoint);
                        }
                    }
                }

                //long end = System.currentTimeMillis();
#if DEBUG
                //Log.Debug("com.mapquest.android.maps.lineoverlay", "Time to process shapepoints: " + (float)(end - start) / 1000.0F + "; no. of points: " + data.Count);
#endif
                canvas.DrawPath(_path, LinePaint);
#if DEBUG
                //Log.Debug("com.mapquest.android.maps.lineoverlay", "Time to draw path shapepoints: " + (float)(System.currentTimeMillis() - end) / 1000.0F + "; no. of points: " + data.Count);
#endif
            }
        }
Esempio n. 6
0
 public MapViewLayoutParams(int width, int height, GeoPoint point, int alignment)
     : base(width, height)
 {
     this.Point = point;
     this.Alignment = alignment;
     if (point != null)
     {
         this.Mode = 0;
     }
 }
Esempio n. 7
0
 public MapViewLayoutParams(LayoutParams source)
     : base(source)
 {
     var lp = source as MapViewLayoutParams;
     if (lp != null)
     {
         this.X = lp.X;
         this.Y = lp.Y;
         this.Point = lp.Point;
         this.Mode = lp.Mode;
         this.Alignment = lp.Alignment;
     }
 }