I am trying to visualize a large amount of weather data with GE(the data may change time to time). Ideally, the user could input the data file with locations and weather data. I was wondering how could I create the KML dynamically?
Based on your comment above you will have KML data available from one of two sources: See my answer to this question: Import KML in Maps API V2 (I would ignore the solution by the author here):
If you have the KML accessable at a publically available URL, follow this part of the API: https://developers.google.com/kml/documentation/mapsSupport.
If you want to load locally stored KML files (i.e. you are getting a .txt file on your server) you will need to parse them yourself. There are libraries for doing this in every language. For Javascript as an example: http://code.google.com/p/geoxml3/
If you do end up doing this with the API (your kml/kmz is available as a URL) your JavaScript code is as simple as:
The API Call to load KML from a URL in the JavaScript API where the map var is your google.maps.Map object.
var geoLayer = new google.maps.KmlLayer('URL');
geoLayer.setMap(map);
UPDATE
Note that this thread is relevant to your question as well, and you do have additional options to loading your KML if using the GE Plugin. Unable to load a local KMZ file into a browser with the google earth plugin using fetchkml function
Related
I am trying to set up tabulator with all it's data validation goodness and simple to use UI in order to help a colleague with CRUD operations on a .txt file he has to do on a daily basis.
I found that tabulator can load data using AJAX but my question is, is it possible to load the data from a .csv/.txt file and then save to the same file?
I know you can export to .csv but without overwriting the loaded data, next time all his work would be lost.
If you are referring to a file on a users local computer then im afraid there is no import from file functionality built in to tabulator, but there is nothing to stop you implementing that bit your self.
The link below is a link to an article that explains how to load a CSV file from an input element in JavaScript,. In the example it loads it into an HTML table, but you could easily alter that to dump it into an array of objects to pass into Tabulators setData function
http://codeanalyze.com/Articles/Details/20174/Read-CSV-file-at-client-side-and-display-on-html-table-using-jquery-and-html5
In terms of saving the data back to the users computer, you would need to use the built in download function, there is no way to save it back to the users computer without the file popup due to browser safety constraints.
But i will add that the above approach is a bit unorthodox. The usual way to handle data persistence would be to save the data back to your server into a database, and then load it back to the client with an ajax request, giving the user the option to download the data when they want the final copy
My website (www.boatingtrax.com) presents maps from google earth and google maps. I prepare the kml files and load the file to my server. I put links to the various kml files on my site (https://www.boatingtrax.com/notices-to-mariners/news-south-wales-notices-mariners/) and google earth formats are generated. NICE!
I update the kml files daily and a new google earth map is generated.
Google Maps is different. I can produce a google map using the kml file and embed the map on site or share the link Both work well. Also nice!
But I have to do that every time I change the kml files (which is daily). Painful!
Could anyone point me to a process so that I can keep Google Maps updated automatically?
Any help appreciated.
If I understand correctly, your issue is that every time you upload a new KML, it has a new filename, and therefore you need to change your Maps API code to point at the new file each time?
If so, you should probably check out KML Network Links. A KML NetworkLink is a small KML file that contains a pointer to another KML file.
In your case, what I would do is create one NetworkLink KML with a static filename, which always points at your latest data KML. Have your Maps API code load the NetworkLink file, and it will show the target KML. Each time you add a new data KML, you just have to upload a new copy of the NetworkLink KML (with the same filename), which points at the new data KML.
For details on KML Network Links, see these resources:
KML Tutorial - Network Links
KML Reference - NetworkLink
A few things to note... Maps API has some caching of KML files built in, so there may be a delay (minutes?) from when you update the NetworkLink file to when you see the new data on your map. Google Earth supports long strings of nested NetworkLinks, but Maps will only follow a limited number of NetworkLinks (10, I think?), so be careful if you go down the road of nesting them. Also, Google Maps API does not support all the KML elements which Earth does... details here.
I'm fairly new to openlayers and I'm trying to simply get a kml to show up on an openlayers map. I have the map and basemap rendering properly in a jsfiddle, after copying out the HTML and javascript from this example here.
I am trying to load a kml that I have hosted on my own domain. The link to it is here. It is just a subset of some water wells data in Alberta, Canada. The code I am using to access the data is:
var vector = new ol.layer.Vector({
source: new ol.source.Vector({
url: 'http://www.cdnpolimap.com/alberta_wells.kml',
format: new ol.format.KML()
})
});
However when I look at other people's maps (mostly in other stackoverflow question), I notice that they are all accessing it without all the http://www......" stuff before it. Am I correct in assuming that the javascript file must be saved on the same domain as the kml and then access it using a relative path? And so therefore I can't access the data when writing in a jsfiddle?
I hosted everything on a single domain and I can now confirm that yes, the kml resource has to exist on the same domain as the js script.
I am trying to use the WEBGL(three.js) file translated through REST api using Autodesk view and Data API.
But, I am not able to download the streaming JSON file, does any one knows about this?
If you need only a specific mesh, you may try as described here: http://adndevblog.typepad.com/cloud_and_mobile/2015/05/viewer-api-search-dwg-solids-by-layer.html and check the following line (that gets the three.js mesh)
var mesh = viewer.impl.getRenderProxy(viewer, fragIdsArray[0]);
And you check this sample for a full download: http://extract.autodesk.io/
I am trying to protect my KML file, from being downloaded or its data extracted easily. All I want is the file to be viewed in google maps or google earth, but no one is allowed to download it or extract the data "easily" (the kml file isnt going to be available publicly). My kml files are a result of deep and exclusive analysis that is a signature I want to hide from competitors.
Also are there any alternatives to convert kml to a format that data cant be obtained easily from it. My KML files have polygons in 3D.
I understand the concept of everything that can be seen can be downloaded or extracted somehow,
I have 4 answers or 0 answers, depending on your project.
Using Google Maps Api for Business (~ 10.000$ per year) you can
generate a Client ID and use that to protect a Fusion Table (can
create in Google Drive) where you can import your KML and which you
then can display using the Google Maps Api. It would be the perfect solution, but without Google Maps Api for Business your Fusion Table is not protected and so anybody can access
it in Google Drive and view and copy-paste the Kml
representation of the polygons.
Using Google Maps Engine (/Lite) you can import your
Kml to Google as well (if you use Lite then you first need to import to Google
"My Maps" and from within Google Maps Engine Lite you can then
import from "My Maps"). I don't know the pricing for non-lite. A
Google Maps Engine Map can be shared so its only viewable and in
this only viewable version I have not found a way to download or
view the raw-kml-data which would be what we want. Sounds all good,
but you are limited to 3 layers in Maps Engine Lite and I have not found a way to import all my polygons (districts in
my case) into one layer at once. I can only import them bit by bit as it seems (managed to import 10 polygons with a total of 353 Points into one layer). Each import results in one layer, can't move stuff from one layer to another and for some reason there are some polygons that I can't seem to import. Edit:
I can import all polygons, one polygon (due to algorithmic simplification of my polygons) got an intersection (line crossing) and as soon as I fixed that part the import didn't throw any errors anymore, but I see now that I can only embed that map using an iframe having the legend included as well, so this solution is nothing for me.
Restrict access to a KML on your server to Google servers only using a white list of Google Maps servers which might request your
KML. Problem: can't find such a list online... must collect in some
way first.
Also there are blog entries Protecting KML Files from general public access in Google
Maps
and Protect KML / KMZ Files from Unauthorized Access Using
Cryptography
Your question is based on a fallacy of computer security known as "security through obscurity". The fallacy is this. You say you don't want it downloaded "easily." You can make it hard, but as long as its possible as soon as one person figures it out they write a script to do it automatically and its then "easy." There is no answer to your question because it is impossible. Any content you make available is pirateable, and any data is reconstructable.
Why not just save the kml file(s) and cut/paste onto a password encrypted usb drive, like Kingston or Kanguru defender. Then just open the kml from your usb disk.
you can check the $_SERVER["HTTP_USER_AGENT"] variable and if is from google then generate the kml from php.
$agent = "Kml-Google";
$google = strpos($_SERVER["HTTP_USER_AGENT"], $agent);
($google !== FALSE) or die;
header('Content-Type: application/vnd.google-earth.kml+xml kml');
header('Content-Disposition: attachment; filename="otras.kml"');
?>
<?xml version="1.0" encoding="UTF-8"?>
<kml xml ...