示例#1
0
 private void addGeoJsonLayerToMap(GeoJsonLayer layer)
 {
     addColorsToMarkers(layer);
     layer.AddLayerToMap();
     // Demonstrate receiving features via GeoJsonLayer clicks.
     layer.SetOnFeatureClickListener(this);
 }
示例#2
0
 private void AddGeoJsonLayerToMap(GeoJsonLayer layer)
 {
     AddColorsToMarkers(layer);
     layer.AddLayerToMap();
     googleMap.MoveCamera(CameraUpdateFactory.NewLatLng(new LatLng(31.4118, -103.5355)));
     // Demonstrate receiving features via GeoJsonLayer clicks.
     layer.SetOnFeatureClickListener(this);
 }
示例#3
0
        protected override void startDemo(bool isRestore)
        {
            if (!isRestore)
            {
                getMap().MoveCamera(CameraUpdateFactory.NewLatLngZoom(new LatLng(51.403186, -0.126446), 10));
            }

            // Shared object managers - used to support multiple layer types on the map simultaneously
            // [START maps_multilayer_demo_init1]
            MarkerManager markerManager = new MarkerManager(getMap());
            //GroundOverlayManager groundOverlayManager = new GroundOverlayManager(getMap());
            //PolygonManager polygonManager = new PolygonManager(getMap());
            //PolylineManager polylineManager = new PolylineManager(getMap());
            // [END maps_multilayer_demo_init1]

            // Add clustering
            // [START maps_multilayer_demo_init2]
            ClusterManager clusterManager = new ClusterManager(this, getMap(), markerManager);

            // [END maps_multilayer_demo_init2]
            getMap().SetOnCameraIdleListener(clusterManager);
            addClusterItems(clusterManager);

            // Add GeoJSON from resource
            try
            {
                var geoJsonOnFeatureClickListener = new GeoJsonOnFeatureClickListener(this);
                // GeoJSON polyline
                // [START maps_multilayer_demo_init3]
                GeoJsonLayer geoJsonLineLayer = new GeoJsonLayer(getMap(), Resource.Raw.south_london_line_geojson, this);//, markerManager, polygonManager, polylineManager, groundOverlayManager);
                // [END maps_multilayer_demo_init3]
                // Make the line red
                GeoJsonLineStringStyle geoJsonLineStringStyle = new GeoJsonLineStringStyle();
                geoJsonLineStringStyle.Color = Color.Red;
                foreach (GeoJsonFeature f in geoJsonLineLayer.Features.ToEnumerable())
                {
                    f.LineStringStyle = geoJsonLineStringStyle;
                }
                geoJsonLineLayer.AddLayerToMap();
                geoJsonLineLayer.SetOnFeatureClickListener(geoJsonOnFeatureClickListener);

                // GeoJSON polygon
                GeoJsonLayer geoJsonPolygonLayer = new GeoJsonLayer(getMap(), Resource.Raw.south_london_square_geojson, this);//, markerManager, polygonManager, polylineManager, groundOverlayManager);
                // Fill it with red
                GeoJsonPolygonStyle geoJsonPolygonStyle = new GeoJsonPolygonStyle();
                geoJsonPolygonStyle.FillColor = Color.Red;
                foreach (GeoJsonFeature f in geoJsonPolygonLayer.Features.ToEnumerable())
                {
                    f.PolygonStyle = geoJsonPolygonStyle;
                }
                geoJsonPolygonLayer.AddLayerToMap();
                geoJsonPolygonLayer.SetOnFeatureClickListener(geoJsonOnFeatureClickListener);
            }
            catch (Java.IO.IOException e)
            {
                Log.Error(TAG, "GeoJSON file could not be read");
            }
            catch (JSONException e)
            {
                Log.Error(TAG, "GeoJSON file could not be converted to a JSONObject");
            }

            // Add KMLs from resources
            try
            {
                var kmlLayerOnFeatureClickListener = new KmlLayerOnFeatureClickListener(this);
                // KML Polyline
                // [START maps_multilayer_demo_init4]
                KmlLayer kmlPolylineLayer = new KmlLayer(getMap(), Resource.Raw.south_london_line_kml, this);//, markerManager, polygonManager, polylineManager, groundOverlayManager, null);
                // [END maps_multilayer_demo_init4]
                // [START maps_multilayer_demo_init6]
                kmlPolylineLayer.AddLayerToMap();
                kmlPolylineLayer.SetOnFeatureClickListener(kmlLayerOnFeatureClickListener);
                // [END maps_multilayer_demo_init6]

                // KML Polygon
                KmlLayer kmlPolygonLayer = new KmlLayer(getMap(), Resource.Raw.south_london_square_kml, this);//, markerManager, polygonManager, polylineManager, groundOverlayManager, null);
                kmlPolygonLayer.AddLayerToMap();
                kmlPolygonLayer.SetOnFeatureClickListener(kmlLayerOnFeatureClickListener);
            }
            catch (XmlPullParserException e)
            {
                e.PrintStackTrace();
            }
            catch (Java.IO.IOException e)
            {
                e.PrintStackTrace();
            }

            // Unclustered marker - instead of adding to the map directly, use the MarkerManager
            // [START maps_multilayer_demo_init5]
            MarkerManager.Collection markerCollection = markerManager.NewCollection();
            markerCollection.AddMarker(new MarkerOptions()
                                       .SetPosition(new LatLng(51.150000, -0.150032))
                                       .SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueAzure))
                                       .SetTitle("Unclustered marker"));
            // [END maps_multilayer_demo_init5]
            // [START maps_multilayer_demo_init7]
            markerCollection.SetOnMarkerClickListener(this);
            // [END maps_multilayer_demo_init7]
        }