locked
add a custom pushpin with Bing Maps and C#

    Question

  • Does anybody know how to add a custom pushpin to a BingMap with C#/Silverlight? I have made an image and I want to use it like pushpin... Thanks!
    Monday, February 22, 2010 3:43 PM

Answers

  • "Bing Maps" comes in lots of different flavours - there are server-side services for doing things like geocoding and routing calculations, and there are client-side controls for creating interactive maps using either javascript or silverlight.

    The two elements of Bing Maps you are going to be most interested in are the Bing Maps AJAX Map Control, and the Bing Maps Silverlight Map Control. Fortunately, both of these have interactive SDKs, which demonstrate all of the functionality and provide sample code listings showing you how to achieve it (including custom pushpins).

    AJAX:
    http://www.microsoft.com/maps/isdk/ajax/
    I want to: -> Customise shapes -> Add custom shapes

    Silverlight:
    http://www.microsoft.com/maps/isdk/silverlight
    I want to: -> Use pushpin layers -> Add a custom pushpin

    If you want to write code in C#, the obvious choice is therefore to use the Silverlight control, but this is not the only option. You can still use the AJAX control via the Bing Maps ASP.Net Control available from codeplex at:
    http://bingmapsasp.codeplex.com/
    This is a wrapper that allows you to write C# code to control the javascript control... so your client still needs to be using a webbrowser with javascript enabled, but you can do your development in C#.

    Or, you can write your own custom map class that requests map imagery from the Bing Maps web services and draws them in your application...


    Beginning Spatial with SQL Server http://www.apress.com/book/view/1430218290
    Monday, February 22, 2010 8:17 PM
    Moderator

All replies

  • Your best bet is to use javascript. I tried doing everything in C# for a long time (because I'm good in C#, and always avoided javascript). But the direction of maps (both google and bing) is to rely heavily on javascript.

    Take a look at the sdk; they've had it pretty simple: http://www.microsoft.com/maps/isdk/ajax/  (just go through the options, flip to "source code", and there's the javascript).

    Take the day or two to wrap your head around the javascript; it's well worth it, and it's not that complicated.

    Monday, February 22, 2010 6:28 PM
  • Thanks, but you mean I have to reform my application in Javascript: I did work more then 3 months on this application and I don't like to change this all in Javascript ;)

    It has to be possible in C# i guess?
    Monday, February 22, 2010 7:06 PM
  • "Bing Maps" comes in lots of different flavours - there are server-side services for doing things like geocoding and routing calculations, and there are client-side controls for creating interactive maps using either javascript or silverlight.

    The two elements of Bing Maps you are going to be most interested in are the Bing Maps AJAX Map Control, and the Bing Maps Silverlight Map Control. Fortunately, both of these have interactive SDKs, which demonstrate all of the functionality and provide sample code listings showing you how to achieve it (including custom pushpins).

    AJAX:
    http://www.microsoft.com/maps/isdk/ajax/
    I want to: -> Customise shapes -> Add custom shapes

    Silverlight:
    http://www.microsoft.com/maps/isdk/silverlight
    I want to: -> Use pushpin layers -> Add a custom pushpin

    If you want to write code in C#, the obvious choice is therefore to use the Silverlight control, but this is not the only option. You can still use the AJAX control via the Bing Maps ASP.Net Control available from codeplex at:
    http://bingmapsasp.codeplex.com/
    This is a wrapper that allows you to write C# code to control the javascript control... so your client still needs to be using a webbrowser with javascript enabled, but you can do your development in C#.

    Or, you can write your own custom map class that requests map imagery from the Bing Maps web services and draws them in your application...


    Beginning Spatial with SQL Server http://www.apress.com/book/view/1430218290
    Monday, February 22, 2010 8:17 PM
    Moderator
  • you need to use HTML tags

    my code may be helpful for you:

    ----------------------------------------------------------------------

     var pin = new Shape(ShapeType.Pushpin, list);

            pin.Title = "Aracın Son Konum Bilgileri";

            pin.Description = description;

            var icon = "";

         icon = "<div style='width:auto'><font size=1>" + plaka + "<font/><img width=32 height=32 src='http://www.atosistakip.com/ATOSIS/img/vehicleicons/car_idling/caryellow.png'/></div>";      

            pin.CustomIcon = icon;

            layer.AddShape(pin); 

    Monday, September 27, 2010 9:05 AM