Hi James,
At first, I want to make sure that we are in the same line. You want to use the javascript to manipulate the map control in the client side, such as add a layer, overlay or something else, am I right? Let’s for example, I want to add a marker to the map control use the scriptable members. We can make some change to the AddAMarker sample (which is located in HowDoISamples/Getting Started/):
[ScriptableTypeAttribute]
public partial class AddAMarker : UserControl
[ScriptableMemberAttribute]
public void AddMarkers()
{
SimpleMarkerOverlay markerOverlay = Map1.Overlays["SimpleMarkerOverlay"] as SimpleMarkerOverlay;
Marker marker = new Marker(-94.558, 39.078);
marker.ImageSource = new BitmapImage(new Uri("/theme/marker_red_shadow.png", UriKind.RelativeOrAbsolute));
marker.Text = "Kansas City";
marker.Foreground = new SolidColorBrush(Colors.Red);
marker.FontSize = 12;
marker.ImageOffsetX = -28;
marker.ImageOffsetY = -32;
TextBlock innerText = new TextBlock();
innerText.Text = "Kansas City";
marker.Popup.Content = innerText;
marker.Popup.Height = 30.0;
marker.Popup.Offset = new Point(10, -30);
markerOverlay.Markers.Add(marker);
markerOverlay.Refresh();
}
Then in the javascript of “Default.aspx” page we write a function named AddAMarker like this:
function AddAMarker() {
var control = document.getElementById('SilverlightMapConnector1');
control.Content.AddAMarker. AddMarkers();}
At last, we have a button the “Default.aspx” page to call the AddAMarker function when you click it, and some markers will be added to the map control.
If there are any misunderstandings please let me know.
Thanks,
Sun