• virtual earth: goodbye pushpin, hello shape


    now that the virtual earth version 5 sdk/control is out and available, some that may want to quickly move to v5 may find some refactoring required.  for me, it was pushpins.  when using v4 of vritual earth, i would normally create a VEPushpin first like this:

    var pin = new VEPushpin(
            someId, // unique identifier of the pin 
            latLon, // a VELatLong object
            "images/custompin.png", // custom pin object
            "some title", // title
            "some details", // details
            "pinIcon", // icon style
            "pinTitle", // pin title style
            "pinDetails"); // pin details style
        
    map.AddPushpin(pin);

    when i changed my app to use the v5 control, that instantly broke.  in v5 the pushpin is elevated to the same level as other shapes (or other shapes are downleveled to the same place, whatever you want to think of it).  now when you want to add a pin with some customization, you will want to create a shape like this:

    var shape = new VEShape(
                      VEShapeType.Pushpin, // the type of shape
                      [latLong] // a VELatLong object
                     );
    
    shape.SetCustomIcon(pinIcon); // if you wanted to set a custom icon
    
    shape.SetTitle("<div class=\"pinTitle\">" + title + "</div>");
    shape.SetDescription("<div class=\"pinDetails\">" + details + "</div>");
    
    map.AddShape(shape);

    as you can see basically it isn't too much work, but essentially everything you add is a "shape" (either a pushpin, polyline, polygon).  the only thing i don't like about the new v5 way of doing things is in the v4 way, you could set the css class of the icon, title, details and it would apply it.  i think that was very simplified and allowed me greater control and separation of my styles from my code.  in v5 i now have to do that within my script.  :-( -- hey VE guys, can we change this?

    of course, all this is documented in the updated , but i thought it might find it helpful real quick-like for those who may happen to read this :-)

    Monday, May 07, 2007 10:00 PM

    PostTypeIcon

Comments.

  • Gravatar
    # re: virtual earth: goodbye pushpin, hello shape


    Note that in V5, using the new code, you're missing the pushpin icon style.

    For this reason, your pushpin icon is not vertically aligned correctly anymore.

    You need something like

    .iconStyle
    {
    position:relative;
    top:-15px;
    }


    shape.SetCustomIcon("<div class='iconStyle' > <img src="images/custompin.png"> </div>");

    5/14/2007 6:06 AM
  • timheuer said:
    Gravatar
    # re: virtual earth: goodbye pushpin, hello shape


    alexandru: good catch! another reason i wish it was just a parameter rather than me have to do it.

    5/14/2007 8:42 AM
  • Gravatar
    # re: virtual earth: goodbye pushpin, hello shape


    Another thing I'd like to be able to do in the Microsoft Earth Map control SDK, version 5.0 and I can't, is this:

    Once a custom icon pushpin is already added to the map, there is no way to reset that icon to the default ?

    The statements below don't work, they don't reset the icon of an existing pushpin.

    shape.SetCustomIcon(null);

    shape.SetCustomIcon("");

    5/14/2007 10:35 PM
  • wloescher said:
    Gravatar
    # re: virtual earth: goodbye pushpin, hello shape


    Slight error in the code...the shape type should be "VEShapeType.Point", rather than "VEShapeType.Pushpin".

    7/19/2007 7:49 AM
  • timheuer said:
    Gravatar
    # re: virtual earth: goodbye pushpin, hello shape


    wloescher: actually Pushpin is right, see http://dev.live.com/virtualearth/sdk

    7/19/2007 8:10 AM
  • tony said:
    Gravatar
    # re: virtual earth: goodbye pushpin, hello shape


    How can I add text in the pushpin in version 5.0 ? Thanks

    10/2/2007 8:20 AM
  • dac le said:
    Gravatar
    # re: virtual earth: goodbye pushpin, hello shape


    Hi Tim,

    While I used "CustomIcon" I've found appears to be an issue in IE 6 and Microsoft Virtual Earth. Whilst the custom icon has a transparent edge to it, the transparent part is appearing blue in the map. This issue does not appear to be present in IE 7.
    Please help me! Thanks alot.

    11/1/2007 3:22 AM

Your Reply.

  Comment Form  

Fields denoted with a "*" are required.

*Your name:
Subject:
Your blog:
Your email:  (will not be displayed)
*Your message:

 
Please add 4 and 6 and type the answer here: