93
Views
13
Comments
Solved
[KML For Google Maps] Unable to add kml
Question
Forge component by Pedro Costa
2
Published on 31 Jan 2019

Hi I am trying to use this component but I just can't seem to add a kml file into it. 

1) I tried using resources folder and change the deploy action to Target Directory. Then I add the link into AddKmltoMap action. But the console states "Unable to retrieve /TestKml/TestPolygon.kml"

2) I tried using a link using both google bucket and dropbox but I got a CORS error.

I am sure I must have made a silly mistake as everyone seems to have used it easily. Please help, I'm new in this. Refer to attached oml file.

TestKml.oml

Staff
Rank: #63
Solution

Hi all,

In order to overcome this limitation you can host the file in dropbox, and in order to overcome the CORS issue you may use a proxy like CORS AnyWhere to make that file available in your sample app.

I did a test with the file that you mentioned. I uploaded to my dropbox and got the share link "https://www.dropbox.com/s/jx0vkkx11hvtwxn/TestPolygon.kml" in order to make this direct link you need to change the www for "dl" (direct link), so dropbox link will not present the preview of the file but returning the file immediately "https://dl.dropbox.com/s/jx0vkkx11hvtwxn/TestPolygon.kml", so this link can be retrieved by the proxy that adds the CORS headers so it can be displayed correctly in your test application:

https://cors-anywhere.herokuapp.com/https://dl.dropbox.com/s/jx0vkkx11hvtwxn/TestPolygon.kml

Hope this helps you to overcome this.


Best regards.

Rank: #45

Chris Chua wrote:

Hi I am trying to use this component but I just can't seem to add a kml file into it. 

1) I tried using resources folder and change the deploy action to Target Directory. Then I add the link into AddKmltoMap action. But the console states "Unable to retrieve /TestKml/TestPolygon.kml"

2) I tried using a link using both google bucket and dropbox but I got a CORS error.

I am sure I must have made a silly mistake as everyone seems to have used it easily. Please help, I'm new in this. Refer to attached oml file.

Hi Chris,


Which OS version you are using?


Rank: #45

Hi Chris,


I can see there is some problem to load your kml file.Please check this.

Rank: #45

Hi Chris,


I got the answer why we are not able to browse kml file.Clarification from OS support as below.
We need to host kml in other server not personal env.


Staff
Rank: #63
Solution

Hi all,

In order to overcome this limitation you can host the file in dropbox, and in order to overcome the CORS issue you may use a proxy like CORS AnyWhere to make that file available in your sample app.

I did a test with the file that you mentioned. I uploaded to my dropbox and got the share link "https://www.dropbox.com/s/jx0vkkx11hvtwxn/TestPolygon.kml" in order to make this direct link you need to change the www for "dl" (direct link), so dropbox link will not present the preview of the file but returning the file immediately "https://dl.dropbox.com/s/jx0vkkx11hvtwxn/TestPolygon.kml", so this link can be retrieved by the proxy that adds the CORS headers so it can be displayed correctly in your test application:

https://cors-anywhere.herokuapp.com/https://dl.dropbox.com/s/jx0vkkx11hvtwxn/TestPolygon.kml

Hope this helps you to overcome this.


Best regards.

Rank: #45

Hi Daniel,


Thank you for clarification but what about if we want this file generated dynamically.

We are generating kml file from the entity and some logic in our app then we wanted to use that kml file in google map to display our location.How can we achieve this?

Staff
Rank: #63

Hi Salman,


Why not use the same approach? 

DropBox has an API that allow us to upload files and host of any type there. So you would generate the file and then upload it and make it available dynamically. 


Hope it helps you.

Best regards