virtual earth: goodbye pushpin, hello shape
| Commentsnow 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 interactive sdk, but i thought it might find it helpful real quick-like for those who may happen to read this :-)
Please enjoy some of these other recent posts...
Comments