Draw shape on bing map in javascript and not silverlight RRS feed

  • Question

  • Hello,
    I am new to using bing map in javascript.
    I created a javascript file and added refernce to bing map and was able to load the bing map on page. Using Visual Studio 2012
    What I want is, I want to allow the  user to draw the shape on the map.
    I am getting mouse down and mouse move click event but not sure how to generate the shape at runtime.
    I have seen couple of methods like Polyline and Circle and others, but that doesn't seems my requirement.
    I want the user to draw any shape he wants.
    Suppose the user wants to draw the shape of star , he should be able to draw it by moving mouse as per that requirment on the map.
    Also, I don't want to use any third party tool like readily avaliable tool, which will do the drawing functionality.
    Please tell me how to do this.


    Monday, December 24, 2012 9:59 AM


All replies

  • Every time the user clicks, capture the location and push it to an array of points - then use that to create a Microsoft.Maps.Polygon. There are loads of such examples, e.g. : http://bingmapsv7modules.codeplex.com/wikipage?title=Shape%20Toolbox%20Module

    twitter: @alastaira blog: http://alastaira.wordpress.com/ | Pro Spatial with SQL Server 2012

    Monday, December 24, 2012 10:05 AM
  • Thanks for the reply.

    Thanks for the link above provided. It displays a toolbar with set of shapes that can be drawn on the map. Actually, I don't want a toolbar with set of predefined shapes. I want to achieve this functionality without a toolbar, means the user will randomly draw any shape that should be drawn. It could be any shape like , circle , star or any other.

    Please if you can provide any code which will help in achieving this functionality, that would be helpful.

    Thanks again for your help and suggestion.


    Monday, December 24, 2012 2:27 PM
  • They're not predefined shapes - they lot you draw freeform polygons, which I think is what you're trying to describe. If you don't want a toolbar, no problem - just look at the code to see how it's done.

    twitter: @alastaira blog: http://alastaira.wordpress.com/ | Pro Spatial with SQL Server 2012

    Monday, December 24, 2012 9:48 PM
  • Thanks for the help. will take a look at the code

    • Marked as answer by sa.sa Thursday, December 27, 2012 9:31 AM
    Tuesday, December 25, 2012 11:32 AM