Host a Google Maps control in your WinForms or WPF application.
NOTE: The Google Maps Javascript API no longer supports the browsers in the samples, but the implementation is not tied to any specific browser. It will still work correctly with more recent browser controls.
To use the wrapper, implement the IGoogleMapHost interface and then use the following code for use with a WPF browser:
public void RegisterScriptingObject(IGoogleMapRequired wrapper)
{
Browser.ObjectForScripting = wrapper;
}
public void SetHostDocumentText(string text)
{
Browser.NavigateToString(text);
}
public object InvokeScript(string methodName, params object[] parameters)
{
return Browser.InvokeScript(methodName, parameters);
}
public bool HandleException(string message, string url, string line)
{
//Log exceptions
return true;
}
Or for a WinForms browser:
public void SetHostDocumentText(string text)
{
browser.DocumentText = text;
}
public void RegisterScriptingObject(IGoogleMapRequired wrapper)
{
browser.ObjectForScripting = wrapper;
}
public object InvokeScript(string methodName, params object[] parameters)
{
return browser.Document.InvokeScript(methodName, parameters);
}
public bool HandleException(string message, string url, string line)
{
//Log exceptions
return true;
}
Then instantiate the wrapper with this line of code:
GoogleMapWrapper.Create(this);