windrobin / winforms-geplugin-control-library

Automatically exported from code.google.com/p/winforms-geplugin-control-library
GNU General Public License v3.0
0 stars 1 forks source link

Cannot access local KML file #12

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Try loading a file from the local machine rather than from a URL

What is the expected output? What do you see instead?
Local KML file should load, it doesn't.

What version of the product are you using? On what operating system?
Latest source, Vista

Please provide any additional information below.
I know this may not really be a bug, but for any practical use, a WinForms 
control really needs access to local files. Do you have a way of allowing 
the webBrowser control to access local KML files? Great control otherwise 
though - good work  :-)

Original issue reported on code.google.com by gordon_m...@hotmail.com on 10 Oct 2009 at 10:35

GoogleCodeExporter commented 9 years ago
Hey, nevermind; I just worked out what I can do (below). However, I think it 
would 
be great if you had another method (FetchKmlLocal) that would read it into a 
tsream 
like I am doing below. I think it would make a lot of people happy  :-)
Again, keep up the good work!!!

geWebBrowser.FetchKml(C:\\test.kml);
FileStream stream = File.Open(textBox1.Text, FileMode.Open, FileAccess.Read);
StreamReader sr = new StreamReader(stream);
IKmlObject kml = ge.parseKml(sr.ReadToEnd());
ge.getFeatures().appendChild(kml);
sr.Close();
stream.Close();

Original comment by gordon_m...@hotmail.com on 10 Oct 2009 at 11:00

GoogleCodeExporter commented 9 years ago
Thanks for this, I will add it in the next commit. Just to note I have amended 
the 
function like so...

{{{
public void FetchKmlLocal(string path)
{
    if (File.Exists(path) && path.EndsWith("kml", true, 
System.Globalization.CultureInfo.CurrentCulture))
    {
        try
        {
            FileStream stream = File.Open(path, FileMode.Open, FileAccess.Read);
            StreamReader reader = new StreamReader(stream);
            IKmlObject kml = geplugin.parseKml(reader.ReadToEnd());
            external.LoadKmlCallBack(kml as IKmlFeature);
        }
        catch (FileNotFoundException fnfex)
        {
            Debug.WriteLine(fnfex.ToString());
            throw;
        }
        catch (UnauthorizedAccessException uaex)
        {
            Debug.WriteLine(uaex.ToString());
            throw;
        }
        catch (COMException cex)
        {
            Debug.WriteLine(cex.ToString());
            throw;
        }
    }
}
}}}

Original comment by fraser.c...@gmail.com on 12 Oct 2009 at 12:50

GoogleCodeExporter commented 9 years ago
Ok it is in, thanks again :D

Original comment by fraser.c...@gmail.com on 12 Oct 2009 at 1:02

GoogleCodeExporter commented 9 years ago
That's excellent! One thing I just noticed to be an issue as well though is 
that my 
KML file specifies some icons to use on my machine and those don't show up for 
the 
same reason I guess - webBorwser not allowed access LOL. Arrghh. I will let you 
know 
if I find a solution, but it doesn't look like an easy one. Maybe you have some 
ideas?

Original comment by gordon_m...@hotmail.com on 12 Oct 2009 at 7:56

GoogleCodeExporter commented 9 years ago
See http://code.google.com/p/winforms-geplugin-control-library/wiki/Server

Original comment by fraser.c...@gmail.com on 26 Nov 2009 at 4:25

GoogleCodeExporter commented 9 years ago
Awesome! Thanks for your hard work!

Original comment by gordon_m...@hotmail.com on 28 Nov 2009 at 2:06