Real pushpins inside the map

May 29, 2009 at 11:09 AM

Hi

Is there any plan to support addings real pushpins to VE? Using:<font size="5">

globe.Host.Geometry.AddGeometry(geometry);

</font>

,

Huge thanks

Javier

Coordinator
May 29, 2009 at 3:28 PM

Yeah, you can do that right now. VEMap.GlobeControl derives from the VE GlobeControl.  You can do all the standard VE API stuff on that, as long as you add references to the MapPoint dlls in your project.  The control doesn't and can't block that functionality.

See also http://virtualearthwpf.codeplex.com/Thread/View.aspx?ThreadId=55345

Who says VEPushPin from this control is not a real pushpin?  :)  IMHO it is more functional for a WPF developer since it interacts with the WPF layout system and you can put anything you want inside of it.

Jun 5, 2009 at 5:12 PM

If I change the perspective of the map is the pushpin perspective changed too? This is real pushpin for me

Coordinator
Jun 5, 2009 at 6:02 PM

No, the pushpin perspective is not affected by the map perspective.  This is true for both VEPushPin and the pushpins on bing.com/maps.  Having the perspective change would decrease readability and usability over having the pushpin always face the user.

If you want to add 3D geometry then your code above is the way to do it.

Jun 5, 2009 at 6:14 PM
Ok, thanks. I think your code is great. Huge thanks
--------------------------------------------------------
Javier Martínez Álvarez
Experto Tecnológico
Servicios para la empresa
--------------------------------------------------------
Telefónica I+D
Parque Tecnológico de Boecillo, parcela 119 y 120
47151 Boecillo, Valladolid
Tel. +34 983 367614
Mov. +34 679751691
Messenger: jamaa06@hotmail.com
Fax +34 983 367564
email: jamaa@tid.es, WEB: www.tid.es
--------------------------------------------------------
Jun 10, 2009 at 1:27 PM

Hi

I have built my class inherit of VEShape with their points and add it to the map.

class MyArea : VEShape {..}

<font size="2" color="#2b91af"><font size="2" color="#2b91af">

MyArea

</font></font><font size="2" color="#2b91af">

 

</font>

shape = new MyArea();

<font size="2">

_veMap.AddShape(shape, "my layer");

</font>

 

but I still have several questions:

1) how can I set the altitude of the area?

2) How can I set the color (fill and stroke)?

Huge thanks

Javier

 

Coordinator
Jun 11, 2009 at 7:36 AM

Take a look at what the AddShape() function does:

public void AddShape(VEShape shape, string layerId)
{
if (shape.ShapeType == VEShapeType.Polyline)
{
List<LatLonAlt> lla = new List<LatLonAlt>();

foreach (VELatLong item in shape.Points)
{
lla.Add(item.ToLatLonAlt());
}

PolyInfo polylineStyle = PolyInfo.DefaultPolyline;
polylineStyle.AltitudeMode = AltitudeMode.FromGround;

this.globeControl.Host.Geometry.AddGeometry(
new PolylineGeometry(
layerId, Guid.NewGuid().ToString(),
lla.ToArray(),
polylineStyle));
}

To set individual altitudes, you'll have to set the altitude on each VELatLong in your shape.Points collection.
To change color, modify some properties on polylineStyle. To use a polygon, which can be filled, look for a PolygonGeometry type (or similar name) instead of PolylineGeometry.

You can add this function to your own code and modify it there as long as you update the references from this.globeControl to the VEMap instance.globeControl
}
Jun 14, 2009 at 8:55 AM

Hi joshb

I have modified your code to add the possibility to add other shapes(bitmaps , polygones, etc.) I share the code with you, maybe you want to add it to your  control, it would be good for us.

The AddShape now is more simple:

 public void AddShape(VEShape shape, string layerId)
        {
             this.globeControl.Host.Geometry.AddGeometry (VEWorldGeometryConverter.Converter(layerId,shape));
        }

And the new class is:

public static class VEWorldGeometryConverter
    {
        public static WorldGeometry Converter(string layerId,VEShape shape)
        {
            switch(shape.ShapeType)
            {
                case VEShapeType.Polyline:
                    {
                        List<LatLonAlt> lla = new List<LatLonAlt>();

                        foreach (VELatLong item in shape.Points)
                        {
                            lla.Add(item.ToLatLonAlt());
                        }

                        PolyInfo polylineStyle = PolyInfo.DefaultPolyline;
                        polylineStyle.AltitudeMode = AltitudeMode.FromGround;

                        return new PolylineGeometry(
                                layerId, Guid.NewGuid().ToString(),
                                lla.ToArray(),
                                polylineStyle);
                    }
                case VEShapeType.RawPushpin:
                    {
                        VERawPushPin rawPushPin = (VERawPushPin)shape;
                        PushpinInfo style = PushpinInfo.Default;
                        style.AltitudeMode = AltitudeMode.FromGround;
                        style.Image = new SimpleBitmapProvider(rawPushPin.Bitmap);
                        RollPitchYaw orientation = new RollPitchYaw(0, -90 * 2*Math.PI/360.0, 0);
                        style.OrientationMode = PushpinOrientationMode.UseProvided;
                        style.Orientation = new Microsoft.MapPoint.Geometry.VectorMath.Orientation(orientation);
                        style.ImageWidth = rawPushPin.Bitmap.Width;
                        style.ImageHeight = rawPushPin.Bitmap.Height;
                        style.MaintainScreenSize = rawPushPin.MaintainScreenSize;
                        style.HitDetect = HitDetectMode.None;

                        return new PushpinGeometry(layerId, Guid.NewGuid().ToString(), rawPushPin.Position.ToLatLonAlt(), style);
                    }
                default:
                    throw new NotSupportedException();
            }
        }
    }

public class VERawPushPin :VEShape
    {
        public VERawPushPin()
        {
            this.ShapeType = VEShapeType.RawPushpin;
        }
        public Bitmap Bitmap { get; set; }
        public VELatLong Position { get; set; }
        public bool MaintainScreenSize { get; set; }
  
    }

Huge thanks

Javier

Huge Thanks

Javier

Coordinator
Jun 14, 2009 at 9:41 PM

jamaa,

That seems like a reasonable addition.  Will test it and integrate with the next update, thanks.

Coordinator
Jun 14, 2009 at 9:42 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.