Why can't my KML file display in Google Maps? [duplicate] - javascript

I have a KML file that I am trying to load into Google maps. It zooms somewhere in the water with no route trace. This is the code I am trying:
var kmlLayer = new google.maps.KmlLayer(kml);
kmlLayer.setMap(this.googlemap);
"this.googlemap" has a Google map object. It is very simple example, but maybe I am missing something or my KML is not in the right format. My KML file can be download here: http://temp-share.com/show/gFHKdyG0Y. Can anyone help?

Google Map needs to be able to access this KML file direclty, in other words, your KML file must be publicly available, and must end with .kml or .kmz extensions (I believe).
To make sure the KML file itself is correct, you can always go to maps.google.com and put the URL in the search bar, it should be automatically recognized and rendered.

As Bill says, the KML file needs to be publicly downloadable, however The URL you linked to in the question abov does not link directly to the file itself, it links to an HTML page that you can visit to download the file. You may have to try a different service, as it doesn't appear that you can download directly from that location without going through the intermediate page.
You will know you are using the right link when you paste the link into the browser, and it immediately prompts you to download the file.
If you still have problems, make sure to post more of your code.

Related

Is `https://drive.google.com/uc?id=(photoID)` is a CDN URL? How much reliable is it?

I am showing images on my web application using this
https://drive.google.com/uc?id=photoID
I am uploading the images on my Google Drive by Google Drive API and then grab the photoID of each uploaded image and then showing them on my web app placing it like this https://drive.google.com/uc?id=photoID. So my question is how much reliable is this approach? Before I have used Facebook url and later those links were no longer available because they are just temporary CDN urls, this time I don't want to made the same mistake again.
Thanks.
Each file in Google Drive has its own id.
Therefore, as long as the file is still stored in the Drive, you will be able to retrieve it and use it for your web application.
According to the Drive documentation:
File IDs are stable throughout the life of the file, even if the file name changes. Search expressions are used to locate files by name, type, content, parent container, owner, or other metadata.
Reference
Files and folders overview.

How to download an asset (zip file) stored on Amazon S3 without having direct access to the bucket

I'm trying to download a zip file stored in an Amazon S3 bucket.
I've found the location of the file in the site's javascript but if I just stick that in the address bar i get 'access denied'.
The zip contains CAD models which are unzipped (presumably remotely) and visualized in a javascript 3D model viewer on the page when loaded.
I have to be logged-in in order to load the page, does this mean I can somehow get access to the zip file?
If it has any relevance, after the file's location URL is an AWSAccessKeyID, Signature and Expiry.
And if it wasn't already obvious, I have no coding experience but I'd really like some pointers if this is even possible.
So I've been blindly messing about and have managed to download the zip file.
I just copied and pasted the javascript code that included the file location in the console. It started with 'JSON.parse' and hey presto a downloadable link appeared! I had no idea it would be so easy.

Modifying local files embedded in a Google Chrome Extension using JS

I have been doing a lot of research and have been unable to find an answer to my exact question. I understand that having a google chrome extension that can write to local user files would be a major security breach and thankfully isn't possible. However in my extension is a .json file that is used to make a HTML webpage with links via JavaScript. The JS reads the .json file and inserts the lines of code on the html page. I am attempting to make a user interface that allows them to update and edit the .json file that is inside the extension in order to add new lines of code to the webpage, but have been unable to find anything that could make this work due to security issues. I was thinking that since the file is in the extension users should be able to modify it.
If that was confusing here is a flow of what I want to happen and where it is not working:
Works:
Users clicks on button that takes them to a webpage hosted in the extension -> when page is loaded, the javascript runs -> the JS looks at a .json file in the extension using an XMLHttpRequest, parses the data, and then inserts it into the html -> The user now see's the content that was contained in the .json file on the html page.
Doesn't work:
After this I would like to have an interface that will allow the user to edit this .json file in order to update the page as they see fit, all in the extension itself.
If it was just me using this extension I could simply use the chrome storage api's available, however this is for my team at work, who are wanting to make edits as we need. Which means we will all be editing the same .json file.
Any information regarding this would be very beneficial. Even if it's as simple as it can't be done. Either way manually editing the .json file without a simple UI is much easier than editing the html directly.
Thanks in advance!
Posts/Articles I have looked at regarding this question:
Access Local Files using a Google Chrome Extension
https://developer.chrome.com/extensions/storage
Local file access with javascript
Allow Google Chrome to use XMLHttpRequest to load a URL from a local file

Load XML data into a KML file with JavaScript

I'm trying to load information from a .xml file (located in a .kmz archive) into the description of a placemark using javascript. The goal is to display the information from the .xml file in an html table in the description. I've gotten everything working, with the exception that I can't seem to access the .xml file from the .kml file. I'm trying to use an XMLHttpRequest() to load the file from the .kmz. It works just fine as an html file, but when i put the html/javascript into a description tag of the .kml, nothing loads at all.
Does anyone know if this is even possible to do? If so, how? If not, any other suggestions?
Thanks in advance for the help!
Is this using the Google Earth API? If so, note that script tags, amongst others, are stripped out by default. You can work around this if needed as described at https://developers.google.com/earth/documentation/balloons#getballoonhtmlunsafe
If this is KML being loaded into the Google Earth client, javascript is allowed (with the exception of things like alerts which bring up a browser dialog).
However it's quite possible, for example if you are loading a separate KMZ in your XHR request, amongst a variety of other reasons, that you're getting a cross domain error (basically because you'll be loading a local file with file:// versus http://). To test this, I would recommend hosting the XML on a server somewhere, and trying to see if that works.
If so, but it does not work locally, please paste a link to your KMZ, or at least paste your main KML within the KMZ, and the associated file structure within the KMZ.

Can Google Earth and Google Maps get live data using KML files?

I've read a little about KML files. They are XML files that can be opened in Google Earth and Google Maps to display all kinds of data on the map. I have created a Google Maps application that displays thousands of dots representing thousands of IP addresses. The dots are red, yellow and green, depending on if they're offline, unstable or online respectively. The dots are also refreshed once per 5 seconds.
I was intrigued by the mention of KML files, seeing as they can be opened in Google Maps and Google Earth both. I have a few worries that I couldn't answer by Googling though:
Can Google Earth be set to update the KML file from a URL live? That way the dots would change colours in the application without the user having to manually
If I were to change my application to using KML files, would it still be a simple matter to fetch information about each dot using javascript?
How does creation of Information Windows work in KML files?
You need to read about NetworkLink on NetworkLink
This element can load KML(KMZ) from url.

Categories

Resources