Example #1
0
        public static void Add3DCar(LocalVectorDataSource source, Projection projection)
        {
            // Add a single 3D model to the vector layer
            // Be sure to add milktruck.nml to your *Assets*, not Drawable, folder (Android)
            string name = "milktruck.nml";

            MapPos   modelPos = projection.FromWgs84(new MapPos(24.646469, 59.423939));
            NMLModel model    = new NMLModel(modelPos, AssetUtils.LoadAsset(name));

            model.Scale = 20;
            model.SetMetaDataElement("ClickText", new Variant("Single model"));

            source.Add(model);
        }
        public static void Add3DCar(LocalVectorDataSource source, Projection projection)
        {
            // Add a single 3D model to the vector layer
            // Be sure to add milktruck.nml to your *Assets*, not Drawable, folder (Android)
            string name = "milktruck.nml";

            MapPos modelPos = projection.FromWgs84(new MapPos(24.646469, 59.423939));
            NMLModel model = new NMLModel(modelPos, AssetUtils.LoadAsset(name));

            model.Scale = 20;
            model.SetMetaDataElement("ClickText", new Variant("Single model"));

            source.Add(model);
        }
        async public static void AddMapOverlays(IMapView mapView)
        {
            // Create overlay layer for markers
            var dataSource   = new LocalVectorDataSource(proj);
            var overlayLayer = new VectorLayer(dataSource);

            mapView.Layers.Add(overlayLayer);

            // Create line style, and line poses
            var lineStyleBuilder = new LineStyleBuilder();

            lineStyleBuilder.Width = 8;

            var linePoses = new MapPosVector();

            // proj.FromWgs84 returns (spherical) Mercator projection
            linePoses.Add(proj.FromWgs84(new MapPos(0, 0)));
            linePoses.Add(proj.FromWgs84(new MapPos(0, 80)));
            linePoses.Add(proj.FromWgs84(new MapPos(45, 45)));

            var line = new Line(linePoses, lineStyleBuilder.BuildStyle());

            dataSource.Add(line);

            // Create balloon popup
            var balloonPopupStyleBuilder = new BalloonPopupStyleBuilder();

            balloonPopupStyleBuilder.CornerRadius      = 3;
            balloonPopupStyleBuilder.TitleFontName     = "Helvetica";
            balloonPopupStyleBuilder.TitleFontSize     = 55;
            balloonPopupStyleBuilder.TitleColor        = new Color(200, 0, 0, 255);
            balloonPopupStyleBuilder.StrokeColor       = new Color(200, 120, 0, 255);
            balloonPopupStyleBuilder.StrokeWidth       = 1;
            balloonPopupStyleBuilder.PlacementPriority = 1;

            var popup = new BalloonPopup(
                proj.FromWgs84(new MapPos(0, 20)),
                balloonPopupStyleBuilder.BuildStyle(),
                "Title", "Description");

            dataSource.Add(popup);

            // Load NML file model from a file
            BinaryData modelFile = AssetUtils.LoadAsset("fcd_auto.nml");

            // set location for model, and create NMLModel object with this
            var modelPos = proj.FromWgs84(new MapPos(24.646469, 59.423939));
            var model    = new NMLModel(modelPos, modelFile);

            mapView.FocusPos = modelPos;
            mapView.Zoom     = 15;

            // Oversize it 20*, just to make it more visible (optional)
            model.Scale = 20;

            // Add metadata for click handling (optional)
            model.SetMetaDataElement("ClickText", new Variant("Single model"));

            // Add it to normal datasource
            dataSource.Add(model);

            // Create and set map listener
            mapView.MapEventListener = new MapListener(dataSource);

            await AnimateModel(model);
        }