Reimers.dk

.NET, AJAX and Google APIs brought together
Welcome to Reimers.dk Sign in | Join | Help
in Search

Labeled markers

Last post 02-04-2010, 12:42 by andes. 7 replies.
Sort Posts: Previous Next
  •  02-09-2009, 4:29 2293

    Labeled markers

    I need to number my markers, and I need various colors. This Labeled marker does exactly what I need.

    Is there any way to easily integrate the mapiconmaker functionality with the Map Control?

    var iconOptions = {};iconOptions.primaryColor = "#FF0000";iconOptions.strokeColor = "#000000";iconOptions.label = "a";iconOptions.labelColor = "#000000";iconOptions.addStar = false;iconOptions.starPrimaryColor = "#FFFF00";iconOptions.starStrokeColor = "#0000FF"; var icon = MapIconMaker.createLabeledMarkerIcon(iconOptions);var marker = new GMarker(map.getCenter(), {icon: newIcon});map.addOverlay(marker); 

    Or, is there another way that I can change the color and label of an icon with the Map Control? 

    Filed under:
  •  02-09-2009, 10:45 2298 in reply to 2293

    Re: Labeled markers

    The best way would be to create a custom icon class that inherits from GoogleIcon.
  •  11-05-2009, 13:33 2852 in reply to 2298

    Re: Labeled markers

    I was about to create a custom version of GoogleIcon but the GoogleIcon class is sealed..

  •  11-05-2009, 22:59 2853 in reply to 2852

    Re: Labeled markers

    I removed sealed from all classes, so if you get the latest code from SVN you can start working, otherwise it will be in the next release.
  •  01-20-2010, 21:27 2954 in reply to 2853

    Re: Labeled markers

    I have labeled markers working with the control. It took a few changes to the labeled marker javascript as well as the GoogleMap control source.

     1. Download the javascript from: http://gmaps-utility-library.googlecode.com/svn/trunk/mapiconmaker/1.1/src/mapiconmaker.js 

    You'll have to modify all of the creation functions in there. Add the line "var id = opts.id;" at the beginning of each function and then after the GIcon is created add "icon.ID = id;"

     2.  In the GoogleMap control source you need to modify GoogleIcon.cs. Change the RenderString function definition from internal string RenderString(GoogleMap map) to public virtual string RenderString(GoogleMap map)

    This is so you can override this function in your custom class. 

    3. Create your custom class. Mine isn't finished, but it is functional. My project is in VB.net, but it should be easy to convert it to C#. You can download it here: http://dl.dropbox.com/u/57205/LabeledGoogleIcon.vb

    Then to use your new icons all you have to do is:

    Dim icon1 As New LabeledGoogleIcon()
    icon1.ID = "GoldIcon"
    icon1.primaryColor = "#ECD58F"

    If you have any questions let me know. Dynamic icons are definitely a cool feature :)

  •  01-21-2010, 23:01 2961 in reply to 2954

    Re: Labeled markers

    Thanks for the VB code. I'll translate it and work it in to the control using your instructions.

    Thanks for the contribution. 

  •  01-22-2010, 15:26 2967 in reply to 2961

    Re: Labeled markers

    Sweet, glad I could help. Please note that the RenderString function I created doesn't set all the available options for a labeled icon. I only needed dynamic colors. But you only need a few extra lines to output everything else like labels and stars.
  •  02-04-2010, 12:42 2989 in reply to 2954

    Re: Labeled markers

    CapnChaos:

    I have labeled markers working with the control. It took a few changes to the labeled marker javascript as well as the GoogleMap control source.

     1. Download the javascript from: http://gmaps-utility-library.googlecode.com/svn/trunk/mapiconmaker/1.1/src/mapiconmaker.js 

    You'll have to modify all of the creation functions in there. Add the line "var id = opts.id;" at the beginning of each function and then after the GIcon is created add "icon.ID = id;"

     2.  In the GoogleMap control source you need to modify GoogleIcon.cs. Change the RenderString function definition from internal string RenderString(GoogleMap map) to public virtual string RenderString(GoogleMap map)

    This is so you can override this function in your custom class. 

    3. Create your custom class. Mine isn't finished, but it is functional. My project is in VB.net, but it should be easy to convert it to C#. You can download it here: http://dl.dropbox.com/u/57205/LabeledGoogleIcon.vb

    Then to use your new icons all you have to do is:

    Dim icon1 As New LabeledGoogleIcon()
    icon1.ID = "GoldIcon"
    icon1.primaryColor = "#ECD58F"

    If you have any questions let me know. Dynamic icons are definitely a cool feature :)

     

    Thanks for the heads up :)


    ***
View as RSS news feed in XML