void AddContent() { InitializeChildGrid(); mainGrid.HorizontalOptions = LayoutOptions.FillAndExpand; mainGrid.VerticalOptions = LayoutOptions.FillAndExpand; mainGrid.BackgroundColor = Color.FromRgb(249, 245, 237); mainGrid.Children.Add(childGrid); maps = new Syncfusion.SfMaps.XForms.SfMaps(); Syncfusion.SfMaps.XForms.ImageryLayer layer = new ImageryLayer(); layer.GeoCoordinates = new Point(38.909804, -77.043442); layer.Radius = 5; CustomMarker marker = new CustomMarker(); marker.Label = "Washington DC"; marker.Latitude = "38.909804"; marker.Longitude = "-77.043442"; layer.MarkerTemplate = mainGrid.Resources["markerTemplate"] as DataTemplate; layer.Markers.Add(marker); MapMarkerSetting markerSettings = new MapMarkerSetting(); markerSettings.VerticalAlignment = MarkerAlignment.Near; markerSettings.TooltipSettings.ShowTooltip = true; markerSettings.TooltipSettings.ValuePath = "Label"; markerSettings.TooltipSettings.FontSize = 15; layer.MarkerSettings = markerSettings; if (Device.RuntimePlatform == Device.UWP) { maps.MinZoom = 2; } maps.Layers.Add(layer); mainGrid.Children.Add(maps); stack = new StackLayout(); stack.Orientation = StackOrientation.Horizontal; stack.BackgroundColor = Color.White; stack.HorizontalOptions = LayoutOptions.EndAndExpand; stack.VerticalOptions = LayoutOptions.End; Label label1 = new Label(); label1.FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Label)); label1.Text = "©"; label1.Margin = new Thickness(2); stack.Children.Add(label1); Label label2 = new Label(); label2.Margin = new Thickness(0, 2, 3, 2); label2.FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Label)); label2.Text = "OpenStreetMap contributors."; label2.TextColor = Color.DeepSkyBlue; Uri uri = new Uri("https://www.openstreetmap.org/copyright"); label2.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(() => Launcher.OpenAsync(uri)) }); stack.Children.Add(label2); mainGrid.Children.Add(stack); }
void AddMainView() { if (childGrid == null) { childGrid = new UIView(); } mainGrid = new UIView(); mainGrid.BackgroundColor = UIColor.FromRGB(243, 239, 233); mainGrid.AddSubview(childGrid); maps = new SFMap(); ImageryLayer layer = new ImageryLayer(); maps.Layers.Add(layer); mainGrid.AddSubview(maps); label1 = new UILabel(); label1.TextColor = UIColor.Black; label1.LayoutMargins = new UIEdgeInsets(2, 2, 3, 2); label1.Font = UIFont.FromName("Helvetica", 12); var text = new NSString("©"); var stringAtribute = new NSDictionary(UIStringAttributeKey.Font, label1.Font, UIStringAttributeKey.ForegroundColor, UIColor.Black); UIStringAttributes strAtr = new UIStringAttributes(stringAtribute); label1.Text = text; label1Size = text.GetSizeUsingAttributes(strAtr); label1.BackgroundColor = UIColor.White; mainGrid.AddSubview(label1); label2 = new UILabel(); label2.TextColor = UIColor.FromRGB(0, 212, 255); label2.LayoutMargins = new UIEdgeInsets(1, 2, 3, 2); label2.Font = UIFont.FromName("Helvetica", 12); var text1 = new NSString("OpenStreetMap contributors."); var stringAtribute1 = new NSDictionary(UIStringAttributeKey.Font, label2.Font, UIStringAttributeKey.ForegroundColor, UIColor.FromRGB(0, 212, 255)); UIStringAttributes strAtr1 = new UIStringAttributes(stringAtribute); label2.Text = text1; label2Size = text1.GetSizeUsingAttributes(strAtr1); label2.BackgroundColor = UIColor.White; label2.UserInteractionEnabled = true; UITapGestureRecognizer tapGesture = new UITapGestureRecognizer(); tapGesture.ShouldReceiveTouch += TapGesture_ShouldReceiveTouch; label2.AddGestureRecognizer(tapGesture); mainGrid.AddSubview(label2); }
void AddContent() { InitializeChildGrid(); mainGrid = new Grid(); mainGrid.HorizontalOptions = LayoutOptions.FillAndExpand; mainGrid.VerticalOptions = LayoutOptions.FillAndExpand; mainGrid.BackgroundColor = Color.FromRgb(249, 245, 237); mainGrid.Children.Add(childGrid); maps = new Syncfusion.SfMaps.XForms.SfMaps(); Syncfusion.SfMaps.XForms.ImageryLayer layer = new ImageryLayer(); if (Device.RuntimePlatform == Device.UWP) { maps.MinZoom = 2; } maps.Layers.Add(layer); mainGrid.Children.Add(maps); stack = new StackLayout(); stack.Orientation = StackOrientation.Horizontal; stack.BackgroundColor = Color.White; stack.HorizontalOptions = LayoutOptions.EndAndExpand; stack.VerticalOptions = LayoutOptions.End; Label label1 = new Label(); label1.FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Label)); label1.Text = "©"; label1.Margin = new Thickness(2); stack.Children.Add(label1); Label label2 = new Label(); label2.Margin = new Thickness(0, 2, 3, 2); label2.FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Label)); label2.Text = "OpenStreetMap contributors."; label2.TextColor = Color.DeepSkyBlue; Uri uri = new Uri("https://www.openstreetmap.org/copyright"); label2.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(() => Device.OpenUri(uri)) }); stack.Children.Add(label2); mainGrid.Children.Add(stack); this.Content = mainGrid; }
void AddGridView() { InitializeChildGrid(); mainGrid = new FrameLayout(sampleContext); mainGrid.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent); mainGrid.AddView(childGrid); maps = new SfMaps(sampleContext); maps.LayoutParameters = new Android.Views.ViewGroup.LayoutParams(Android.Views.ViewGroup.LayoutParams.MatchParent, Android.Views.ViewGroup.LayoutParams.MatchParent); ImageryLayer layer = new ImageryLayer(); maps.Layers.Add(layer); mainGrid.AddView(maps); mainGrid.SetClipChildren(false); LinearLayout linear = new LinearLayout(sampleContext); linear.Orientation = Orientation.Horizontal; linear.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent); linear.SetHorizontalGravity(GravityFlags.End); linear.SetVerticalGravity(GravityFlags.Bottom); TextView textView1 = new TextView(sampleContext); textView1.Text = "©"; textView1.SetBackgroundColor(Color.White); textView1.SetTextColor(Color.Black); textView1.SetPadding(2, 2, 2, 2); linear.AddView(textView1); TextView textView2 = new TextView(sampleContext); textView2.Text = "OpenStreetMap contributors."; textView2.SetTextColor(Color.DeepSkyBlue); textView2.SetPadding(0, 2, 3, 2); textView2.SetBackgroundColor(Color.White); textView2.Clickable = true; textView2.Click += TextView2_Click; linear.AddView(textView2); mainGrid.AddView(linear); }
void AddGridView() { InitializeChildGrid(); mainGrid = new FrameLayout(sampleContext); mainGrid.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent); mainGrid.AddView(childGrid); maps = new SfMaps(sampleContext); maps.ZoomLevel = 4; maps.MinZoom = 4; maps.MaxZoom = 10; maps.LayoutParameters = new Android.Views.ViewGroup.LayoutParams(Android.Views.ViewGroup.LayoutParams.MatchParent, Android.Views.ViewGroup.LayoutParams.MatchParent); layer = new ImageryLayer(); layer.GeoCoordinates = new PointF(27.1751f, 78.0421f); PopulationMarker marker1 = new PopulationMarker(sampleContext); marker1.Latitude = 20.6843f; marker1.Longitude = -88.5678f; layer.Markers.Add(marker1); PopulationMarker marker2 = new PopulationMarker(sampleContext); marker2.Latitude = -13.1631f; marker2.Longitude = -72.5450f; layer.Markers.Add(marker2); PopulationMarker marker3 = new PopulationMarker(sampleContext); marker3.Latitude = -22.9519f; marker3.Longitude = -43.2106f; layer.Markers.Add(marker3); PopulationMarker marker4 = new PopulationMarker(sampleContext); marker4.Latitude = 41.8902; marker4.Longitude = 12.4922; layer.Markers.Add(marker4); PopulationMarker marker5 = new PopulationMarker(sampleContext); marker5.Latitude = 30.3285; marker5.Longitude = 35.4444; layer.Markers.Add(marker5); PopulationMarker marker6 = new PopulationMarker(sampleContext); marker6.Latitude = 27.1751; marker6.Longitude = 78.0421; layer.Markers.Add(marker6); PopulationMarker marker7 = new PopulationMarker(sampleContext); marker7.Latitude = 40.4319; marker7.Longitude = 116.5704; layer.Markers.Add(marker7); maps.Adapter = new MarkerAdapter(sampleContext); maps.Layers.Add(layer); mainGrid.AddView(maps); mainGrid.SetClipChildren(false); List <int> arrayList = new List <int>(); arrayList.Add(Resource.Drawable.Mexico); arrayList.Add(Resource.Drawable.Peru); arrayList.Add(Resource.Drawable.Christ); arrayList.Add(Resource.Drawable.Colosseum); arrayList.Add(Resource.Drawable.Petra); arrayList.Add(Resource.Drawable.TajMahal); arrayList.Add(Resource.Drawable.China_wall); List <string> descriptionList = new List <string>(); descriptionList.Add("Mayan ruins on Mexico's Yucatan Peninsula. It was one of the largest Maya cities, thriving from around A.D. 600 to 1200."); descriptionList.Add("An inca citadel built in the mid-1400s. It was not widely known until the early 20th century."); descriptionList.Add("An enormous statue of Jesus Christ with open arms. A symbol of Christianity across the world, the statue has also become a cultural icon of both Rio de Janeiro and Brazil."); descriptionList.Add("Built between A.D. 70 and 80. It is one of the most popular touristattractions in Europe."); descriptionList.Add("It is a historic and archaeological city in southern Jordan. Petra lies around Jabal Al-Madbah in a basin surrounded by mountains which form the eastern flank of the Arabah valley that runs from the Dead Sea to the Gulf of Aqaba."); descriptionList.Add("It is an ivory-white marble mausoleum on the southern bank of the river Yamuna in the Indian city of Agra."); descriptionList.Add("The Great Wall of China is a series of fortifications that were built across the historical northern borders of ancient Chinese states and Imperial China as protection against various nomadic groups from the Eurasian Steppe."); List <string> headerList = new List <string>(); headerList.Add("Chichen Itza, Mexico"); headerList.Add("Machu Picchu, Peru"); headerList.Add("Chirst the Redeemer, Brazil"); headerList.Add("Colosseum, Rome"); headerList.Add("Petra, Jordan"); headerList.Add("Taj Mahal, India"); headerList.Add("Great wall of China, China"); DisplayMetrics displayMetrics = sampleContext.Resources.DisplayMetrics; float screenWidth = displayMetrics.WidthPixels; float screenHeight = displayMetrics.HeightPixels; var density = displayMetrics.Density; LinearLayout layout = new LinearLayout(sampleContext); layout.Orientation = Orientation.Horizontal; layout.SetPadding(0, 0, 0, 10); layout.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent); layout.SetVerticalGravity(GravityFlags.Bottom); var itemWidth = screenWidth * 0.7; SfCarousel carousel = new SfCarousel(sampleContext); carousel.RotationAngle = 0; carousel.ItemWidth = (int)itemWidth; carousel.ItemHeight = (int)(110 * sampleContext.Resources.DisplayMetrics.Density); carousel.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, carousel.ItemHeight); carousel.SelectedIndex = 5; carousel.SelectedItemOffset = (int)(carousel.ItemWidth / 2) - (int)(carouselGap * density); List <SfCarouselItem> dataSource = new List <SfCarouselItem>(); for (int i = 0; i <= 6; i++) { LinearLayout linearLayout = new LinearLayout(sampleContext); linearLayout.SetBackgroundColor(Color.White); linearLayout.Orientation = Orientation.Horizontal; linearLayout.SetBackgroundResource((Resource.Drawable.carousel_corner_radius)); linearLayout.LayoutParameters = new Android.Views.ViewGroup.LayoutParams((int)itemWidth, (int)carousel.ItemHeight); var width = (int)(0.6f * itemWidth); LinearLayout layout1 = new LinearLayout(sampleContext); layout1.Orientation = Orientation.Vertical; layout1.LayoutParameters = new Android.Views.ViewGroup.LayoutParams((int)width, (int)carousel.ItemHeight); layout1.SetPadding(15, 15, 15, 15); TextView textView = new TextView(sampleContext); textView.Text = headerList[i]; textView.SetTypeface(Typeface.Default, TypefaceStyle.Bold); textView.TextAlignment = TextAlignment.TextStart; textView.LayoutParameters = new Android.Views.ViewGroup.LayoutParams(width - 30, ViewGroup.LayoutParams.WrapContent); layout1.AddView(textView); textView = new TextView(sampleContext); textView.Text = descriptionList[i]; textView.SetMaxLines(3); textView.Ellipsize = Android.Text.TextUtils.TruncateAt.End; textView.TextAlignment = TextAlignment.TextStart; textView.SetPadding(0, 10, 0, 0); textView.LayoutParameters = new Android.Views.ViewGroup.LayoutParams(width - 30, ViewGroup.LayoutParams.WrapContent); layout1.AddView(textView); linearLayout.AddView(layout1); SfCarouselItem sfCarouselItem = new SfCarouselItem(sampleContext); width = (int)(0.4f * itemWidth); LinearLayout layout2 = new LinearLayout(sampleContext); layout2.SetPadding(10, 15, 15, 15); layout2.LayoutParameters = new Android.Views.ViewGroup.LayoutParams(width, carousel.ItemHeight); ImageView imageView = new ImageView(sampleContext); imageView.SetBackgroundResource((Resource.Drawable.carousel_corner_radius)); imageView.SetImageResource(arrayList[i]); imageView.SetScaleType(ImageView.ScaleType.FitXy); imageView.ClipToOutline = true; layout2.AddView(imageView); linearLayout.AddView(layout2); sfCarouselItem.ContentView = linearLayout; dataSource.Add(sfCarouselItem); } carousel.DataSource = dataSource; carousel.SelectionChanged += Carousel_SelectionChanged; layout.AddView(carousel); mainGrid.AddView(layout); LinearLayout linear = new LinearLayout(sampleContext); linear.Orientation = Orientation.Horizontal; linear.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent); linear.SetHorizontalGravity(GravityFlags.End); linear.SetVerticalGravity(GravityFlags.Bottom); TextView textView1 = new TextView(sampleContext); textView1.Text = "©"; textView1.SetBackgroundColor(Color.White); textView1.SetTextColor(Color.Black); textView1.SetPadding(2, 2, 2, 2); linear.AddView(textView1); TextView textView2 = new TextView(sampleContext); textView2.Text = "OpenStreetMap contributors."; textView2.SetTextColor(Color.DeepSkyBlue); textView2.SetPadding(0, 2, 3, 2); textView2.SetBackgroundColor(Color.White); textView2.Clickable = true; textView2.Click += TextView2_Click; linear.AddView(textView2); mainGrid.AddView(linear); }
void AddContent() { InitializeChildGrid(); mainGrid.HorizontalOptions = LayoutOptions.FillAndExpand; mainGrid.VerticalOptions = LayoutOptions.FillAndExpand; mainGrid.BackgroundColor = Color.FromRgb(249, 245, 237); mainGrid.Children.Add(childGrid); maps = new Syncfusion.SfMaps.XForms.SfMaps(); layer = new ImageryLayer(); layer.GeoCoordinates = new Point(27.1751, 78.0421); maps.MaxZoom = 8; maps.MinZoom = 4; layer.DistanceType = DistanceType.KiloMeter; if (Device.RuntimePlatform == Device.Android) { layer.Radius = 1500; } else { layer.Radius = 500; } //layer.MarkerTemplate = mainGrid.Resources["markerTemplate"] as DataTemplate; CustomMarker marker = new CustomMarker(); marker.Latitude = "20.6843"; marker.Longitude = "-88.5678"; marker.Location = "Mexico"; layer.Markers.Add(marker); marker = new CustomMarker(); marker.Location = "Peru"; marker.Latitude = "-13.1631"; marker.Longitude = "-72.5450"; layer.Markers.Add(marker); marker = new CustomMarker(); marker.Location = "Brazil"; marker.Latitude = "-22.9519"; marker.Longitude = "-43.2106"; layer.Markers.Add(marker); marker = new CustomMarker(); marker.Location = "Rome"; marker.Latitude = "41.8902"; marker.Longitude = "12.4922"; layer.Markers.Add(marker); marker = new CustomMarker(); marker.Location = "Jordan"; marker.Latitude = "30.3285"; marker.Longitude = "35.4444"; layer.Markers.Add(marker); marker = new CustomMarker(); marker.Location = "India"; marker.Latitude = "27.1751"; marker.Longitude = "78.0421"; layer.Markers.Add(marker); marker = new CustomMarker(); marker.Location = "China"; marker.Latitude = "40.4319"; marker.Longitude = "116.5704"; layer.Markers.Add(marker); MapMarkerSetting markerSettings = new MapMarkerSetting(); markerSettings.IconSize = 20; markerSettings.IconColor = Color.FromHex("#FF2196ef"); markerSettings.TooltipSettings.TooltipTemplate = mainGrid.Resources["toolTipTemplate"] as DataTemplate; markerSettings.TooltipSettings.ShowTooltip = true; markerSettings.TooltipSettings.FontSize = 15; layer.MarkerSettings = markerSettings; maps.Layers.Add(layer); mainGrid.Children.Add(maps); carousel = new Syncfusion.SfCarousel.XForms.SfCarousel(); carousel.RotationAngle = 0; if (Device.RuntimePlatform == Device.UWP) { carousel.HeightRequest = 150; carousel.ItemHeight = 150; } else { carousel.HeightRequest = 125; carousel.ItemHeight = 125; } carousel.VerticalOptions = LayoutOptions.EndAndExpand; carousel.Margin = new Thickness(0, 0, 0, 5); carousel.ItemTemplate = mainGrid.Resources["carouselTemplate"] as DataTemplate; carousel.SelectionChanged += Carousel_SelectionChanged; carousel.ItemsSource = viewModel.RotatorItems; carousel.SelectedIndex = 5; mainGrid.Children.Add(carousel); stack = new StackLayout(); stack.Orientation = StackOrientation.Horizontal; stack.BackgroundColor = Color.White; stack.HorizontalOptions = LayoutOptions.EndAndExpand; stack.VerticalOptions = LayoutOptions.End; Label label1 = new Label(); label1.FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Label)); label1.Text = "©"; label1.Margin = new Thickness(2); stack.Children.Add(label1); Label label2 = new Label(); label2.Margin = new Thickness(0, 2, 3, 2); label2.FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Label)); label2.Text = "OpenStreetMap contributors."; label2.TextColor = Color.DeepSkyBlue; Uri uri = new Uri("https://www.openstreetmap.org/copyright"); label2.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(() => Launcher.OpenAsync(uri)) }); stack.Children.Add(label2); mainGrid.Children.Add(stack); }
void AddMainView() { if (childGrid == null) { childGrid = new UIView(); } mainGrid = new UIView(); mainGrid.BackgroundColor = UIColor.FromRGB(243, 239, 233); mainGrid.AddSubview(childGrid); maps = new SFMap(); maps.ZoomLevel = 4; maps.MinimumZoom = 4; maps.MaximumZoom = 10; layer = new ImageryLayer(); layer.GeoCoordinates = new CGPoint(27.1751, 78.0421); PopulationMarker marker1 = new PopulationMarker(); marker1.Latitude = 20.6843f; marker1.Longitude = -88.5678f; layer.Markers.Add(marker1); PopulationMarker marker2 = new PopulationMarker(); marker2.Latitude = -13.1631f; marker2.Longitude = -72.5450f; layer.Markers.Add(marker2); PopulationMarker marker3 = new PopulationMarker(); marker3.Latitude = -22.9519f; marker3.Longitude = -43.2106f; layer.Markers.Add(marker3); PopulationMarker marker4 = new PopulationMarker(); marker4.Latitude = 41.8902; marker4.Longitude = 12.4922; layer.Markers.Add(marker4); PopulationMarker marker5 = new PopulationMarker(); marker5.Latitude = 30.3285; marker5.Longitude = 35.4444; layer.Markers.Add(marker5); PopulationMarker marker6 = new PopulationMarker(); marker6.Latitude = 27.1751; marker6.Longitude = 78.0421; layer.Markers.Add(marker6); PopulationMarker marker7 = new PopulationMarker(); marker7.Latitude = 40.4319; marker7.Longitude = 116.5704; layer.Markers.Add(marker7); maps.Layers.Add(layer); maps.Delegate = new OSMDelegate(this); mainGrid.AddSubview(maps); carousel = new SfCarousel(); carousel.RotationAngle = 0; carousel.SelectedIndex = 5; carousel.SelectionChanged += Carousel_SelectionChanged; mainGrid.AddSubview(carousel); label1 = new UILabel(); label1.TextColor = UIColor.Black; label1.LayoutMargins = new UIEdgeInsets(2, 2, 3, 2); label1.Font = UIFont.FromName("Helvetica", 12); var text = new NSString("©"); var stringAtribute = new NSDictionary(UIStringAttributeKey.Font, label1.Font, UIStringAttributeKey.ForegroundColor, UIColor.Black); UIStringAttributes strAtr = new UIStringAttributes(stringAtribute); label1.Text = text; label1Size = text.GetSizeUsingAttributes(strAtr); label1.BackgroundColor = UIColor.White; mainGrid.AddSubview(label1); label2 = new UILabel(); label2.TextColor = UIColor.FromRGB(0, 212, 255); label2.LayoutMargins = new UIEdgeInsets(1, 2, 3, 2); label2.Font = UIFont.FromName("Helvetica", 12); var text1 = new NSString("OpenStreetMap contributors."); var stringAtribute1 = new NSDictionary(UIStringAttributeKey.Font, label2.Font, UIStringAttributeKey.ForegroundColor, UIColor.FromRGB(0, 212, 255)); UIStringAttributes strAtr1 = new UIStringAttributes(stringAtribute); label2.Text = text1; label2Size = text1.GetSizeUsingAttributes(strAtr1); label2.BackgroundColor = UIColor.White; label2.UserInteractionEnabled = true; UITapGestureRecognizer tapGesture = new UITapGestureRecognizer(); tapGesture.ShouldReceiveTouch += TapGesture_ShouldReceiveTouch; label2.AddGestureRecognizer(tapGesture); mainGrid.AddSubview(label2); }