I am working on a WPF application that uses the built-in WebBrowser to display Bing Maps. The code can draw polygons on the map, which we are trying to export as KML using the Microsoft.Maps GeoXML module:
Microsoft.Maps.loadModule('Microsoft.Maps.GeoXml', function () {
// Pass in the map to export all data into an XML string
try {
var xml = Microsoft.Maps.GeoXml.write(map, {
xmlFormat: Microsoft.Maps.GeoXmlFormat.kml,
roundLocations: true,
indentChars: ' '
});
}
catch (e) {
alert(e)
}
However, this code gives the following error: Port number should be an integer
I have looked online and can't find anything about what this error means. The Microsoft documentation doesn't seem to require any kind of port number, and the map itself (which supposedly uses the same setup) works fine (aside from a few script errors).
Possibly helpful information
- The .htm that we load into the WebBrowser is set up to call methods from a C# helper class. We also sometimes invoke the javascript methods from C#.
- The actual map functions properly for the most part, but there is a script error when hovering over the dropdown to select the map type. I'm not sure if this points to a problem in our overall setup or not.
- We have nearly identical javascript in our web project, and get no errors. The only difference is the callbacks to our C# class.
Attempted Fixes
I tried to get a stack trace from the error, but it was undefined.
I have used the code at this link to make sure that the web browser is using the proper version of Internet Explorer. However, I don't get these errors running the .htm in Internet Explorer.