The Interactive SDK> Customize SHapes>Add Custom shapes example displays the custom icon with the text "Shape" plus it's ID. Here is the source:

var icon = "<div style='font-size:12px;font-weight:bold;borderTongue Tiedolid 2px Black;background-color:Aqua;width:50px;'>Shape</div>";

However, I cant find anywhere in the source where the ID number is added to the word "Shape" that is between the DIV tags.

My problem is that I need to use text from another control on the page and place it where the "Shape" word is between the DIV tags, but I cant figure out how . I have tried:


and to simplify by removing the reference to the other control:


Both of these scripts work fine in a normal <div> tag but neither works when wrapped inside the SetCustomIcon method.

I am hoping that if I can see how the SDK example is adding a variable between the DIV tags, I might figure out a better approach.....uhh...one that works!

Re: Variable in setCustomIcon ?


Not quite sure what your question is... this is what I use for placing pins on my map with a custom icon:
Code Snippet
var YourShapeIDinfo = "<img src='images/YourShapeIDimage.png'>"
latlong = new VELatLong(-53.83820892, -146.44835472)
YourShapeID = new VEShape(VEShapeType.Pushpin, latlong);
YourShapeID.SetTitle('Your Shape Title');

Line by line breakdown:
1. Setting the HTML for the description section of the pushpin (see line 6)
2. The lat/long placement
3. Creates the shape (type, location)
4. Sets the custom icon from an image
5. Sets the title of the push pin
6. Calls the data from the first line so I can make the description have all sorts of HTML.

Now, I think you are asking how to get the custom pin icon from a variable you have Try taking the html out of the actual "SetCustomIcon" method, and then just make it a variable. Something like:

Code SnippetC

var IconVariable = "CODE FOR YOUR IMAGE"


Now, I am brand new to JS, so this is just my best guess. I think part of your problem might be that you are trying to get a variable from outside the function. According to w3school.org:


When you declare a variable within a function, the variable can only be accessed within that function. When you exit the function, the variable is destroyed. These variables are called local variables. You can have local variables with the same name in different functions, because each is recognized only by the function in which it is declared.

If you declare a variable outside a function, all the functions on your page can access it. The lifetime of these variables starts when they are declared, and ends when the page is closed.

So I guess that means that if you have a variable set in another function, you won't be able to use it. Not really sure what to do, but document.GetElementById() might work. Some more details about the situation might be helpful to those who actually know what they are talking about Stick out tongue

Re: Variable in setCustomIcon ?


Thanks for the reply. I will try your suggestion of declaring the HTML outside the setCustomIcon method. I noticed the interactive SDK used that technique, but the MSDN reference placed the HTML inside the method's argument....which is the way I did it.

You are right about variable scope. In my case, I will use the value of a control which is global (getElementById.....)

Re: Variable in setCustomIcon ?


It was a simple syntax error. Am I the only intellisence-addict that is useless with NOTEPAD

This works:

var theUser = document.getElementById("User2).value;

pin2.setCustomIcon("<div>" + theUser + "</div>");