void DetailsMap_TargetViewChanged(object sender, MapEventArgs e) { GeoCoordinate center = DetailsMap.TargetCenter; mapHasMoved = true; if (DetailsMap.TargetZoomLevel >= minZoomLevel) { viewModel.LoadStopsForLocation(center); } #if DEBUG cacheRectLayer.Children.Clear(); int roundingLevel = 2; int multiplier = 3; double positiveOffset = (Math.Pow(.1, roundingLevel) * 0.5) / multiplier; double negativeOffset = (Math.Pow(.1, roundingLevel) * 0.5) / multiplier; double lat = Math.Round(center.Latitude * multiplier, roundingLevel) / multiplier; double lon = Math.Round(center.Longitude * multiplier, roundingLevel) / multiplier; // Round off the extra decimal places to prevent double precision issues // from causing multiple cache entires GeoCoordinate roundedLocation = new GeoCoordinate( Math.Round(lat, roundingLevel + 1), Math.Round(lon, roundingLevel + 1) ); MapPolygon cacheSquare = new MapPolygon(); cacheSquare.Locations = new LocationCollection(); cacheSquare.Locations.Add(new GeoCoordinate(roundedLocation.Latitude + positiveOffset, roundedLocation.Longitude + positiveOffset)); cacheSquare.Locations.Add(new GeoCoordinate(roundedLocation.Latitude - negativeOffset, roundedLocation.Longitude + positiveOffset)); cacheSquare.Locations.Add(new GeoCoordinate(roundedLocation.Latitude - negativeOffset, roundedLocation.Longitude - negativeOffset)); cacheSquare.Locations.Add(new GeoCoordinate(roundedLocation.Latitude + positiveOffset, roundedLocation.Longitude - negativeOffset)); cacheSquare.Stroke = new SolidColorBrush(Colors.Black); cacheSquare.StrokeThickness = 5; cacheRectLayer.Children.Add(cacheSquare); Pushpin requestCenterPushpin = new Pushpin(); requestCenterPushpin.Location = roundedLocation; cacheRectLayer.Children.Add(requestCenterPushpin); CenterControl deadCenter = new CenterControl(); cacheRectLayer.AddChild(deadCenter, center, PositionOrigin.Center); #endif }