当前位置: 首页>>代码示例>>C#>>正文


C# MKMapView.DequeueReusableAnnotationView方法代码示例

本文整理汇总了C#中MKMapView.DequeueReusableAnnotationView方法的典型用法代码示例。如果您正苦于以下问题:C# MKMapView.DequeueReusableAnnotationView方法的具体用法?C# MKMapView.DequeueReusableAnnotationView怎么用?C# MKMapView.DequeueReusableAnnotationView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MKMapView的用法示例。


在下文中一共展示了MKMapView.DequeueReusableAnnotationView方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnGUI

    void OnGUI()
    {
        KitchenSink.OnGUIBack();

        if (CoreXT.IsDevice) {

            GUILayout.BeginArea(new Rect(50, 50, Screen.width - 100, 100));
            GUILayout.BeginHorizontal();

            if (GUILayout.Button("Show Map", GUILayout.ExpandHeight(true))) {
                if (mapView == null) {
                    mapView = new MKMapView(new Rect(25, 100, Screen.width/2 - 50, Screen.height/2 - 150));

                    // create custom annotation view
                    mapView.viewHandler = delegate(MKMapView view, MKAnnotation annotation) {
                        // try to reuse old view
                        var annotationView = mapView.DequeueReusableAnnotationView("annoview");
                        if (annotationView == null) {
                            Debug.Log("creating new annotation view");
        //							annotationView = new MKPinAnnotationView(annotation, "annoview");
                            annotationView = new MKAnnotationView(annotation, "annoview");
                            annotationView.canShowCallout = true;

                            var image = new UIImage(new NSData(new NSURL("http://u3dxt.com/wp-content/uploads/2013/06/gears_14662320_s-225x225.jpg")));
                            annotationView.image = image;
                        } else {
                            Debug.Log("reusing old annotation view");
                            annotationView.annotation = annotation;
                        }

                        return annotationView;
                    };
                }

                UIApplication.deviceRootViewController.view.AddSubview(mapView);

                MKCoordinateRegion newRegion = new MKCoordinateRegion();
                newRegion.center.latitude = 37.786996;
                newRegion.center.longitude = -122.440100;
                newRegion.span.latitudeDelta = 0.112872;
                newRegion.span.longitudeDelta = 0.109863;

                mapView.SetRegion(newRegion, true);
            }

            if (GUILayout.Button("Hide Map", GUILayout.ExpandHeight(true))) {
                mapView.RemoveFromSuperview();
            }

            if (GUILayout.Button("Add marker", GUILayout.ExpandHeight(true))) {
                Annotation ggBridge = new Annotation(new CLLocationCoordinate2D(37.810000, -122.477450),
                    "Golden Gate Bridge", "Opened: May 27, 1937");
                mapView.AddAnnotation(ggBridge);
            }

            if (GUILayout.Button("Clear marker", GUILayout.ExpandHeight(true))) {
                mapView.RemoveAnnotations(mapView.annotations);
            }

            GUILayout.EndHorizontal();
            GUILayout.EndArea();
        }

        //		OnGUILog();
    }
开发者ID:bruteostrich,项目名称:GnomeArena,代码行数:65,代码来源:MapsTest.cs


注:本文中的MKMapView.DequeueReusableAnnotationView方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。