Open Ms Access from Google Earth

JT Kent

Registered User.
Local time
Today, 09:13
Joined
Aug 26, 2010
Messages
50
Hello Guys,
I have linked my Ms Access database application with Google Earth and it works perfectly.

Now i want to create a hyperlink on a Google Earth Placemark/Location that if clicked will revert control back to the Database Application and update a combo box in the database based on the location selected.

For instance, Let's assume i have a Location/Placemark called Texas in the Google Earth Application. Clicking the Location called "Texas" should revert control back to the Database and set a combobox called "Selected Location" to Texas.

I need your help urgently please.
CHEERS!!!
 
How have you linked Access to Google Earth?
 
Hello Guys,
I have linked my Ms Access database application with Google Earth and it works perfectly.
Yep - How is important. Are you using the program with the COM library or do you have your own webpage and you have built a Google Earth instance using the API.

In any case you should know that the COM library is no longer being supported and will die eventually. You only option soon will be the Google Earth API.

Here is my OLD example of this which is in need of an update. Note that you can at first run GE without a website but I think eventually you will need to have one.


http://www.access-programmers.co.uk/forums/showthread.php?t=168131&highlight=google+earth

Now i want to create a hyperlink on a Google Earth Placemark/Location that if clicked will revert control back to the Database Application and update a combo box in the database based on the location selected.

Assuming you are using GE API - the trick to get things from a webbrowser back to MSAccess is for MSAcces to be "listening" for any navigation that takes place. You then in the BeforeNavigation event cancel the navigation. But the URL that you navigate to is a code for something and you use this to do something. You will see this in my example. From what I know in VBA there is no other way of doing this.

So in GE your hyperlink will have in it somwhere - ".cbo...Texas...." (it does not really matter what as long as texas is there.

User clicks on hyperlink.
Beforenavigate fires
Cancel navigation
Get URL and parse out your information
CBO = Change Combo Box
Text = what you want to change it to.
 
Hello Darbid,
Thanks for your response. From your previous mail, you mentioned that Google Earth no longer supports COM APIs. Besides loading Google Earth on my form will be complex especially when there are no examples of doing this in VBA.

What is your advice then on how i can solve the issue i raised?
I have run out of ideas and dont know what to do next.

The codes in your attached database are not working so i do not have an idea of how the application works.

Anybody who can help with this problem will be greatly appreciated. Please refer to the mail trail above.

Thank you.
 
Hello Darbid,
Thanks for your response. From your previous mail, you mentioned that Google Earth no longer supports COM APIs. Besides loading Google Earth on my form will be complex especially when there are no examples of doing this in VBA.

You want to have a placemark and clicking on this place mark will update your database. As far as I know this means you want to control your own instance of Google earth.

If you just want place marks and to show an address in google earth/google maps you could make a simple URL which would do this, but you would then use googles own website. I then dont think you can have interaction back from GE to your database.

To have interaction you need to understand my example.

There are a number of reasons why this example does not work - It is old - it was never intended to work out of the box - things have changed. To give people a workingexample I would have to point the .mde to a working webpage. As I do not want the traffic I have not done that. I might ask the forum but I doubt they would want to do this.

Here are the steps;


  • Look at my example and understand the code and how it works.
  • It points to a local file containing HTML which loads an instance of the Google Earth server.
  • You can then with the use of JScript send messages to functions built into the HTMl which cause the earth to do things.
  • Clicking on certain things causes an attempt to navigate and see how I capture this attempt and use the expected information in the BeforeNavigation event.


  • If you follow all these things then you will have to create your own HTML file with an instance of GE.
  • I think for testing you can use a HTML file locally
  • IF you read GE TOS you will see that you must have a publically accessible internet page.
  • Thus I used a free website for mine.
  • You then register with GE your website address - otherwise it will not work.
  • Then you set about writing your code.
Remember my advice here is because you are looking for 2 way communication. It would be much easier if you just wanted to show something on the earth. With that you could just use any google website or you could use the GE program and open a .klm file which contains all the data of your point.

Instead of broad questions may I suggest you ask specific ones - I like them better and it gives me confidence that you are learning. I am happy to help as I too have a lot to learn.
 
There are a number of reasons why this example does not work - It is old - it was never intended to work out of the box - things have changed.

Hi Darbid,
Thanks for your speedy response. I really appreciate it.

Although, i do understand the steps you have asked me to follow, It is difficult for me to comprehend your code since the application is not functioning properly.

Also, i am a complete newbie to JScript so i really dont know what to do next.
How do i create a HTML File with an instance of Google Earth?

Thanks
 
Hi Darbid,
Thanks for your speedy response. I really appreciate it.
Your Welcome...please remember I learn by helping, i do not know everything.


In my example there is a file with .HTML simply open this file in FireFox or InternetExplorer. You must have google earth ActiveX control installed.

http://code.google.com/apis/earth/

Once open you are hosting your very own version of Google Earth. You can play with it with your mouse. But we have no interactions yet.


Also, i am a complete newbie to JScript so i really dont know what to do next.
Welcome to the club. I only learnt enough to be dangerous with a website and Google Earth.

You must understand that most people use Google earth with a website / server and just buttons on the webbrowser. What we are doing is putting that website in an Acces form and then getting the two to communicate.

From Access to Webbrowser and thus GE

Look at my HTML file. You will see this
Code:
function AddContract(pl_ID,pl_Name,i_Type,po_Lat,po_Long,pl_Lic_Name,pl_Lic_Counsel,pl_DOC){
  var placemark = ge.createPlacemark(pl_ID);
THis is a function and under it is the engine of the function.

To call this function look in the VBA code and you will find this

Code:
Dim pl_Id As String 'The ID of the placemark
Dim pl_Name As String 'The name of the placemark
Dim pl_Type As String 'type which most likely will be a http link
Dim i_Type As String 'the type of icon which is also a link
Dim po_Lat As Single 'the latitude of the placemark
Dim po_Long As Single 'the longitude of the placemark
Dim pl_Lic_Name As String 'the name of the licensee
Dim pl_Lic_Counsel As String 'the name of the licenseing counsel
Dim pl_DOC As Date 'the date of the contract


pl_Id = 5784931099#
pl_Name = "My New Pin Point Label"
i_Type = "http://maps.google.com/mapfiles/ms/micons/blue-pushpin.png"
po_Lat = -31.4268394510138
po_Long = 152.890726652801
pl_Lic_Name = "This Is Where you can Put a Label"
pl_Lic_Counsel = "Something Else"
pl_DOC = "30/01/1973"


Call mydoc.parentWindow.execScript("AddContract('" & pl_Id & "','" & pl_Name & "','" & i_Type & "', " & _
                    "'" & po_Lat & "','" & po_Long & "','" & pl_Lic_Name & "','" & pl_Lic_Counsel & "','" & pl_DOC & "')", "Jscript")
This last bit is the actual communication with the webbrowser and the function.

You will see each button on the VBA code calls a function that you can find in the HTML.

Communication from Webbrowser to VBA / Access

Answer to this is IMPOSSIBLE - happy to be proven wrong. (.NET can do it)

So the work around is the webbrowser tries to navigate and the URL that it tries to navigate to contains the information you want to give to Access. You then catch this URL in the BeforeNavigate event and read the URL and CANCEL the navigation. An example of this is

In the VBA you will see the MakethisHome button which calls this function in the HTML

Code:
function myhomeview(){
    var la = ge.getView().copyAsLookAt(ge.ALTITUDE_RELATIVE_TO_GROUND);
    window.location = ('01' + la.getLatitude() + ';' + la.getLongitude() + ';' + la.getRange());
}
This function just tries to navigate to a new website "Window.location" will try to make the navigation. In the URL will be first the path to the .HTML file and then for example this
0129.298374637;20.4849548;200
This comes from
('01' + la.getLatitude() + ';' + la.getLongitude() + ';' + la.getRange())
So that is

01 = my code to know I am dealing with make this home in my VBA
; = you can use this to parse a string into different parts
latitude = is exactly that - the latitude which GE gives
; = a new part
longitude = GE longitude
; the range

you can see me getting the information back out here

Code:
    Select Case Left(strfrombrowser, 2)  [COLOR=Red][B]' this will give me the 01 ie the first 2 number[/B][/COLOR]

        Case 1
        
            strfrombrowser = Right$(strfrombrowser, (Len(strfrombrowser) - 2))
            Lat_split = Split(strfrombrowser, ";")(0)   [COLOR=Red][B]' this gives me the information to the first ;  see the split function in VBA[/B][/COLOR]
            Long_Split = Split(strfrombrowser, ";")(1)
            Range_Split = Split(strfrombrowser, ";")(2)
            MsgBox "Output for Make this home - Latitude = " & Lat_split & ". Longatude = " & Long_Split & _
            ". The Range = " & Range_Split & "."
            
        Case 2
            strfrombrowser = Right$(strfrombrowser, (Len(strfrombrowser) - 2))
            strfrombrowser = Left$(strfrombrowser, (Len(strfrombrowser) - 2))
            PlacemarkID = strfrombrowser
            MsgBox PlacemarkID
            
        Case 3


        Case 4



        Case 5


    End Select
How do i create a HTML File with an instance of Google Earth?
Thanks

And here is where the learning curve for you starts. You are going to have to learn a bit of JScript / a little HTML and then get up to date with Googles API for google earth.

http://code.google.com/apis/earth/documentation/

examples;

http://code.google.com/apis/earth/documentation/examples.html

The only good thing I can think of is that every where on the internet that you see Google earth you can right click and view the source code and you will see how they did it. Otherwise I do not like it.

I have added a file below. The forum will not allow me to have a .HTML file but download this file and change it to .HTML then open it in Firefox or IE. This is Google earth in its most basic form. Note there is a SCRIPT section which does the work for Google Earth and Google Maps. Then in the BODY it basically says where to place Google Earth in a Webpage.

Ahh I know why my example does not work. It was built with Internet Explorer 6....it really hates it if you have IE7 or IE8.

You need to delete the Active X control from the form and put it there again. Then name it the same name. Then what I suggest is to comment out all the code in the BeforeNavigate and just put there a Debug.print URL. This will then give you an idea of what I mean. And the example will work.
 

Attachments

To call this function look in the VBA code and you will find this

Code:
Dim pl_Id As String 'The ID of the placemark
Dim pl_Name As String 'The name of the placemark
Dim pl_Type As String 'type which most likely will be a http link
Dim i_Type As String 'the type of icon which is also a link
Dim po_Lat As Single 'the latitude of the placemark
Dim po_Long As Single 'the longitude of the placemark
Dim pl_Lic_Name As String 'the name of the licensee
Dim pl_Lic_Counsel As String 'the name of the licenseing counsel
Dim pl_DOC As Date 'the date of the contract


pl_Id = 5784931099#
pl_Name = "My New Pin Point Label"
i_Type = "http://maps.google.com/mapfiles/ms/micons/blue-pushpin.png"
po_Lat = -31.4268394510138
po_Long = 152.890726652801
pl_Lic_Name = "This Is Where you can Put a Label"
pl_Lic_Counsel = "Something Else"
pl_DOC = "30/01/1973"


Call mydoc.parentWindow.execScript("AddContract('" & pl_Id & "','" & pl_Name & "','" & i_Type & "', " & _
                    "'" & po_Lat & "','" & po_Long & "','" & pl_Lic_Name & "','" & pl_Lic_Counsel & "','" & pl_DOC & "')", "Jscript")
This last bit is the actual communication with the webbrowser and the function.

Hello Darbid,
You have been very helpful. Thanks again.
I have a clearer picture of how your example works but there is an error in the Call mydoc.parentWindow.execScript function.

The browser keeps displaying an error message.
I do have a question though.

How can i display a KML/KMZ File that shows (about 3 or more placemarks at once) in the web browser within the Ms Access form?

Answer to this is IMPOSSIBLE - happy to be proven wrong. (.NET can do it)

So the work around is the webbrowser tries to navigate and the URL that it tries to navigate to contains the information you want to give to Access. You then catch this URL in the BeforeNavigate event and read the URL and CANCEL the navigation. An example of this is

In the VBA you will see the MakethisHome button which calls this function in the HTML

Code:
function myhomeview(){
    var la = ge.getView().copyAsLookAt(ge.ALTITUDE_RELATIVE_TO_GROUND);
    window.location = ('01' + la.getLatitude() + ';' + la.getLongitude() + ';' + la.getRange());
}
This function just tries to navigate to a new website "Window.location" will try to make the navigation. In the URL will be first the path to the .HTML file and then for example thisThis comes from So that is

01 = my code to know I am dealing with make this home in my VBA
; = you can use this to parse a string into different parts
latitude = is exactly that - the latitude which GE gives
; = a new part
longitude = GE longitude
; the range

you can see me getting the information back out here

Code:
    Select Case Left(strfrombrowser, 2)  [COLOR=Red][B]' this will give me the 01 ie the first 2 number[/B][/COLOR]

        Case 1
        
            strfrombrowser = Right$(strfrombrowser, (Len(strfrombrowser) - 2))
            Lat_split = Split(strfrombrowser, ";")(0)   [COLOR=Red][B]' this gives me the information to the first ;  see the split function in VBA[/B][/COLOR]
            Long_Split = Split(strfrombrowser, ";")(1)
            Range_Split = Split(strfrombrowser, ";")(2)
            MsgBox "Output for Make this home - Latitude = " & Lat_split & ". Longatude = " & Long_Split & _
            ". The Range = " & Range_Split & "."
            
        Case 2
            strfrombrowser = Right$(strfrombrowser, (Len(strfrombrowser) - 2))
            strfrombrowser = Left$(strfrombrowser, (Len(strfrombrowser) - 2))
            PlacemarkID = strfrombrowser
            MsgBox PlacemarkID
            
        Case 3


        Case 4



        Case 5


    End Select

I still need further clarification on how the browser will communicate with my Ms Access form. Please remember that when you click on a Location in the browser, you see the properties in a small pop and clicking the "location" hyperlink from the pop up must update a Textbox in the Access form to the selected Location's name.

For instance, clicking Texas (from the browser) brings out a pop up. Then clicking "Texas Location" from the pop up must update the Location's textbox to "Texas" (in the Access form).

The only good thing I can think of is that every where on the internet that you see Google earth you can right click and view the source code and you will see how they did it. Otherwise I do not like it.

Finally, i have tried the above but to no avail. How do you go about that?

Thanks again Darbid.
 
The browser keeps displaying an error message.

That does not help me. My crytal ball is broken. What do you execute in VBA - what function in the HTML is called - what message do you get? I assume you are able to see google earth on your own page now?

By the way in the beforenavigate you need just this to see what the Browser is sending you

Code:
If Not virginbrowser Then
Cancel = True
End If

Debug.Print URL
Then go to Australia > New South Wales

Then click on ADD POINT in the access form. This will add a yellow Marker to a great town called Port Macquarie. If you click this marker a pop-up will appear. If you click the link in the popup the browser will try to navigate.

How can i display a KML/KMZ File that shows (about 3 or more placemarks at once) in the web browser within the Ms Access form?
I only know that answer to this in theory, as to be honest I could not get this to work. You can record actions in the Google Earth Program which will be saved into a KML file. KMZ is just zipped. Now from the webbrowser you cannot upload a KMZ file from your local computer directly to GE. GE only reads these files from the webserver. Thus you would need to be hosting a server to do it. I also think that you can make your KML on the fly and give it directly to GE as a string, I think I tried this and could not get it to work, but it has been a while since I tried.


I still need further clarification on how the browser will communicate with my Ms Access form. Please remember that when you click on a Location in the browser, you see the properties in a small pop and clicking the "location" hyperlink from the pop up must update a Textbox in the Access form to the selected Location's name.

GE also does not have a crytal ball. When you click on the earth you get nothing, you have to code what happens when the user clicks on the earth. Further GE alone will not give you an address. GE will only give you lat/long co-ordinates. So you would need to first code a function for GE to give you the lat/long of the the mouse click. Then you would have to use an HTTP call to another service privider which gives you an address from the lat/long. From this you would easily get Texas.

In fact you will see in my address example that I first give Google Maps and address - Google Maps returns the Lat/Long and then I give Google Earth the Lat/Long and we fly there.

For instance, clicking Texas (from the browser) brings out a pop up. Then clicking "Texas Location" from the pop up must update the Location's textbox to "Texas" (in the Access form).
So to do this you will have to first code the creation of the pop up, and where it should be placed. In the pop-up you can add a link and from this link it will communicate with Access with whatever you put in the URL.

Finally, i have tried the above but to no avail. How do you go about that?
What I mean is if you right click any web page you can view the source code of the page.
 
Hi Darbid,
I have been trying to get some work done but it has not been smooth thus far.

May be it will help if i explain the logic behind my application.
If you remember (one of your previous mails), you attached a Google Earth instance in the form of a notepad document.

What i would like to do is to open the webbrowser which will allow the Google Earth instance to load from the "Form Load " Event in my VBA code. Then further navigation can be done by clicking other buttons such as loading a kml file.

So i tweaked your code and used the HTML version of the Google Earth instance file you gave me (instead of the test.html file) in the Form Load event. But i keep getting the following error message:

Error Message Dialog Appears:
The expression On Open you entered as the event property setting produced the following error: User defined type not defined.
1)The expression may not result in the name of a macro, the name of a user-defined function, or [Event Procedure]
2)There may have been an error evaluating the function, event, or macro
What could be responsible for this?


I only know that answer to this in theory, as to be honest I could not get this to work. You can record actions in the Google Earth Program which will be saved into a KML file. KMZ is just zipped. Now from the webbrowser you cannot upload a KMZ file from your local computer directly to GE. GE only reads these files from the webserver. Thus you would need to be hosting a server to do it. I also think that you can make your KML on the fly and give it directly to GE as a string, I think I tried this and could not get it to work, but it has been a while since I tried..

From your statement above, it sounds like it is next to impossible to load a KML file into a webbrowser. Can you give me the syntax for calling a JScript function from VBA?

The following illustration will explain my question better.

After embedding my KML code in VBA, i want to use the LoadKMlData function to load a KML file in my browser (there will be a button that if clicked will trigger this action). How can i do this? Is this really possible?

Code for LoadKmlData
Dispatch googleEarth = new Dispatch("GoogleEarth.ApplicationGE");
Dispatch.call(googleEarth,"LoadKmlData ",new Variant(kml)); Dispatch

Thanks so much.
 
Can you put an example here please. I would suggest you put the example.mdb and .html file in a folder and then zip the folder.

Then post that.
 
Hello Darbid,
I attached 2 files to this mail. The named document called "HTML File" is just an instance of the Google Earth browser while the named document called "KML File" is the KML File i wish to load after clicking "Load KML Doc" from the Access Form.

The instance of Google earth i.e. "HTML File" should load from the Form Load method of the Access form.

I assume to load the KML document into the browser, i have to store the KML code in a string and call the LoadKMLData method. This string is called KML in this case.

Below is the call to the method but what am not sure is where this line of code should appear.

Dispatch googleEarth = new Dispatch("GoogleEarth.ApplicationGE");
Dispatch.call(googleEarth,"LoadKmlData ",new Variant(kml)); Dispatch


Could you explain better the objects in your codes such as VirginBrowser,NAVcounter,mydoc,parsenewstring,strfrombrowser and the other methods associated with WebBrowser4 such as WebBrowser4_BeforeNavigate2.

Finally, the most important of the tasks at hand is how the webbrowser will communicate with Ms Access i.e the combobox in the form.

Thanks again.
 

Attachments

The instance of Google earth i.e. "HTML File" should load from the Form Load method of the Access form.
yes it should, in the load you just navigate to your html file at this stage. But later you will have to have your own website.

I assume to load the KML document into the browser, i have to store the KML code in a string and call the LoadKMLData method. This string is called KML in this case.
Good luck with this. I tried and failed. We can look at it again but I was not successful. But yes you cannot give google earth a file from C drive for example. You can either give it a file from your webserver or you must give it a string containing the KML stuff.

Below is the call to the method but what am not sure is where this line of code should appear.

Dispatch googleEarth = new Dispatch("GoogleEarth.ApplicationGE");
Dispatch.call(googleEarth,"LoadKmlData ",new Variant(kml)); Dispatch

That I think is the method to load a kml file whats more I think this is intended as an initial event of the webpage so that a KML is read at the same time that GE is started.

Could you explain better the objects in your codes such as VirginBrowser,NAVcounter,mydoc,parsenewstring,strfrombrowser and the other methods associated with WebBrowser4 such as WebBrowser4_BeforeNavigate2.

I would like you to understand them by doing but I will explain some.

VirginBrowser and NAVcounter you will see are used to know when to start capturing and cancelling the beforenavigates. When GE loads it navigates a few times and you have to let them go though. It is different when it is on a webserver.

http://msdn.microsoft.com/en-us/library/aa768326(VS.85).aspx

before navigate is the trick to communication. As you can see from the linke it fires BEFORE the webbrowser navigates. Thus it gives you the opportunity to cancel the navigation.

Have a look at my button command6.

Note that I even wrote there I failed to get this to work. but in theory in the Html there is this function below. The Function name is parsenewstring (this is my function) and it accepts one variable named "strmykml". Then the function uses the ge object and calles two methods of the GE API. one to parsekml and the second to add the object pentagon to the GE with appendChild.

Code:
function parsenewstring(strmykml){
var pentagon = ge.parseKml(strmykml);

  ge.getFeatures().appendChild(pentagon);
}
The way Access can start the above is with this call. You can see the name of the function in there and how I have put the variable in there "xstr" which is a string that contains kml.
Code:
Call mydoc.parentWindow.execScript("parsenewstring('" & (CStr(xstr)) & "')", "Jscript")
Buddy I am going to avoid your questions on this KML stuff cause I never got it to work. There is a problem in the type of string to give GE - although I think it was a bug and it might now be fixed.

Finally, the most important of the tasks at hand is how the webbrowser will communicate with Ms Access i.e the combobox in the form.

Thanks again.

I am not sure how to explain this differently. The only way is that the browser tries to navigate to fake URLs. Access stops the navigation but reads the URL which actually contains the information.


for example imagine your coded webpage as the following URL hyperlink

www.google.com/01i am a cool dude

Then in your webbrowser control in the BeforeNavigate you have

cancel = true
if instr(URL, "01") then

msgbox right(URL, 16)

end if


Then Access would now show you a message box with "I am a cool dude"

Thus you are now sending information from the webbrowser to access.

As far as I know this trick of using the URL is the only way.

Your questions lead me still to thinking that you have not got access to load a test.html file.

Just try to get one loaded. Then post your code with a .mdb and .html file.

I would like to see you load it and that you can see what is happening in the events of the webbrowser.
 
it appears they have fixed the KML problem and it was a bug. The latest version of GE works with my button to lead KML. My KML makes a yellow PIN in the middle of Australia, with a popup.
 
yes it should, in the load you just navigate to your html file at this stage. But later you will have to have your own website.

Thanks buddy but do i really have to own my website for this purpose? Can you throw more light to this?

before navigate is the trick to communication. As you can see from the linke it fires BEFORE the webbrowser navigates. Thus it gives you the opportunity to cancel the navigation.

This makes sense. But in the scenario i have, when a location is clicked in the browser, a pop-up dialog appears with hyperlinks. It's on clicking one of these hyperlinks that the Access Combobox is updated. Does this approach still apply in that case?

Have a look at my button command6.

Note that I even wrote there I failed to get this to work. but in theory in the Html there is this function below. The Function name is parsenewstring (this is my function) and it accepts one variable named "strmykml". Then the function uses the ge object and calles two methods of the GE API. one to parsekml and the second to add the object pentagon to the GE with appendChild.

Code:
function parsenewstring(strmykml){
var pentagon = ge.parseKml(strmykml);

  ge.getFeatures().appendChild(pentagon);
}
The way Access can start the above is with this call. You can see the name of the function in there and how I have put the variable in there "xstr" which is a string that contains kml.
Code:
Call mydoc.parentWindow.execScript("parsenewstring('" & (CStr(xstr)) & "')", "Jscript")
Buddy I am going to avoid your questions on this KML stuff cause I never got it to work. There is a problem in the type of string to give GE - although I think it was a bug and it might now be fixed.

In your last post, you mentioned that the bug has now been fixed. Does this mean i can now Load KML files to my browser

Thanks buddy.
 
Thanks buddy but do i really have to own my website for this purpose? Can you throw more light to this?

read it all but in particular 9.1 and decide for youself. http://code.google.com/apis/maps/terms.html


This makes sense. But in the scenario i have, when a location is clicked in the browser, a pop-up dialog appears with hyperlinks. It's on clicking one of these hyperlinks that the Access Combobox is updated. Does this approach still apply in that case?
So you want hyperlinks on the popup - so in that hyperlink you will have to have the message you want to give to access - whether that is the city, the latitude and longitude or whatever you want to give access.


In your last post, you mentioned that the bug has now been fixed. Does this mean i can now Load KML files to my browser

Thanks buddy.
I think you can load KML files as a file, but the kml file will have to be on a webserver, you cannot upload a file locally. You can also take a kml file and read it into a string and give it the string. I have test this yesterday and it now works. My old example does this.
 
it appears they have fixed the KML problem and it was a bug. The latest version of GE works with my button to lead KML. My KML makes a yellow PIN in the middle of Australia, with a popup.

Hello Darbid,
I assume your statement above means loading KML files to the browser is possible afterall. Please which version of google earth am i supposed to use to accomplish this.

Finally, i tried to zoom into one of the Locations in my KML File from the browser but apparently, the map has that same Location existing already in the browser. For instance, if my KML file has a Location called "Texas", the real Location "Texas" will also be displayed in my browser therby showing "2 -Texas names" on the browser.

A further issue is that when i click on the location (Texas in this example), it displays multiple Texas locations with icons representing them. Idon't want this what can i do.

I will be expecting my answers in the previous mail.
Thanks again.
 
please post your KML file, html file and mdb example.
 
Thank you so much for your help thus far Darbid,
i really appreciate your kind gesture.

There are 3 files in the attached folder named "Example". The KML file is called "KML Sample - copy.txt", the database is called "MyExample" while the JScript file is called "Trial" (pretty much the same as the file you sent me earlier).

I saw your last post saying i can now send KML Files as a String to GE. Please which version of GE exactly can do this. Testing your last example still does not work on my PC.

In fact the following code
Call mydoc.parentWindow.execScript("parsenewstring('" & (CStr(xstr)) & "')", "Jscript")

after assigning the string variable "xstr" to the KML file now returns an error message : RunTime Error '-2147352319 (80020101), Automation error.

What could be responsible for this?

Thanks again
 

Attachments

I have seen your example. You kml string must be poorly formed. I dont know where.


comment yours out and copy this below. THEN look at Australia :-)



xstr = "<?xml version=""1.0"" encoding=""UTF-8""?>" & _
"<kml xmlns=""http://earth.google.com/kml/2.1"">" & _
"<Document>" & _
"<name>startinglocation.kml</name>" & _
"<Style id=""PushPin63"">" & _
"<IconStyle>" & _
"<Icon>" & _
"<href>http://maps.google.com/mapfiles/kml/pal3/icon63.png</href>" & _
"</Icon>" & _
"</IconStyle>" & _
"</Style>" & _
"<StyleMap id=""PushPin"">" & _
"<Pair><key>normal</key><styleUrl>#PushPin63</styleUrl></Pair>" & _
"<Pair><key>highlight</key><styleUrl>#PushPin55</styleUrl></Pair>" & _
"</StyleMap>" & _
"<Style id=""PushPin55"">"

xstr = xstr & "<IconStyle>" & _
"<scale>1.1</scale>" & _
"<Icon>" & _
"<href>http://maps.google.com/mapfiles/kml/pal3/icon55.png</href>" & _
"</Icon>" & _
"</IconStyle>" & _
"<LabelStyle>" & _
"<scale>1.1</scale>" & _
"</LabelStyle></Style>" & _
"<Placemark id=""default_starting_location"">" & _
"<name>Australia</name>" & _
"<LookAt>" & _
"<longitude>133</longitude>" & _
"<latitude>-27</latitude>" & _
"<altitude>0</altitude>" & _
"<range>11001000</range>" & _
"<tilt>0</tilt>" & _
"<heading>0</heading><flyToView>1</flyToView>" & _
"</LookAt>" & _
"<styleUrl>#PushPin</styleUrl>" & _
"<Point><coordinates>133,-27,0</coordinates></Point></Placemark></Document>" & _
"</kml>"

So now do you have a smile on your face :-)


next steps is to add my other events like the beforenavigate etc and put a debug.print in it and see the navigations that take place - there is I think 1 at the beginning - you have to let that go through ie NOT cancel it, then cancel any others.

Then create a kml string with a html string in the popup.

Once you have got all that in place post back your mdb and html file.

See my code then for reading a kml file. You could try that now.

Great work so far.
 

Users who are viewing this thread

Back
Top Bottom