AnsweredAssumed Answered

Update control on DockPane

Question asked by bulla_b on Aug 4, 2017
Latest reply on Aug 8, 2017 by bulla_b

Following the BingStreetside sample on GitHub, I have created a MapTool and a DockPane.  On the DockPaneI have a WebBroswer control that I want to update when I click on the map with the MapTool.  I am having troubles referencing the DockPanel from the MapTools click event.

 

Here is a snippet of the Dockpane.xaml for the WebBrowser:

 

<Grid Margin="0">
<WebBrowser x:Name="streetViewControl" Margin="0" />
</Grid>

 

 

Here is the code I am using in Dockpane.xaml.cs:

 

namespace StreetView_ArcPro
{
/// <summary>
/// Interaction logic for DockpaneView.xaml
/// </summary>
public partial class DockpaneView : UserControl //public partial
{
public DockpaneView()
{
InitializeComponent();
streetViewControl.Navigated += StreetViewControl_Navigated;
streetViewControl.Navigate("http://maps.google.ca");
}

public void SetMapLocation(double lng, double lat)
{
streetViewControl.Navigate(@"http://maps.google.ca/maps?q=" + lat + "," + lng + "&num1&s11=" + lat + "," + lng + "&sspn=16.71875,56.536561&ie=UTF8&ll=" + lat + "," + lng + "&spn=0.020401,0.028753&z=15&layer=c&cbll=" + lat + "," + lng + "&panoid=&cbp=12,161.92,,0,5");
}

private void StreetViewControl_Navigated(object sender, NavigationEventArgs e)
{
MessageBox.Show("Navigated");
}
}
}

 

 

And here is the code for the MapTool.  See comments for where I am running into problems:

 

namespace StreetView_ArcPro
{
public class StreetView_Tool : MapTool
{
public StreetView_Tool()
{
IsSketchTool = true;
SketchType = SketchGeometryType.Point;
SketchOutputMode = SketchOutputMode.Map;
}

protected override Task OnToolActivateAsync(bool active)
{
return base.OnToolActivateAsync(active);
}

protected override Task<bool> OnSketchCompleteAsync(Geometry geometry)
{
double lat;
double lng;

var coord = GeometryEngine.Instance.Project(geometry, SpatialReferences.WGS84) as MapPoint;
if (coord != null)
{
lng = coord.X;
lat = coord.Y;


//**********This is where I want to call the SetMapLocation on the DockPane, but I have no idea how to do it***********

//**********This next two line do not give me errors, but it just doesn't work.*******

 

var sample = new DockpaneView();
sample.SetMapLocation(lng, lat);


}

var ret = QueuedTask.Run(() =>
{
return true;
}
);

return ret;

//return base.OnSketchCompleteAsync(geometry);
}

}
}

 

 

Any assistance is appreciated.

 

Thanks!

Outcomes