Working, including URL fetch.

This commit is contained in:
Simon Brooke 2020-02-25 14:17:02 +00:00
parent 47ca5b17ba
commit 5cbcaa85a1
No known key found for this signature in database
GPG key ID: A7A4F18D1D4DF987
3 changed files with 133 additions and 19 deletions

View file

@ -122,8 +122,8 @@ crossorigin=""/>
<li>
For each <code>div</code> which you wish to contain a map view,
an invocation of the function
<code>geocsv_lite.core.initialise_map_element(id, data-source)</code>: <br/>
<samp>&lt;script&gt;geocsv_lite.core.initialise_map_element("map", "data/data.csv");&lt;/script&gt;</samp>
<code>geocsv_lite.core.initialiseMapElement(id, data-source)</code>: <br/>
<samp>&lt;script&gt;geocsv_lite.core.initialiseMapElement("map", "data/data.csv");&lt;/script&gt;</samp>
</li>
</ol>
<p>
@ -159,6 +159,12 @@ crossorigin=""/>
and you don't have an appropriate pin image for each value present,
then you will get 'broken' pin images appearing on your map.
</p>
<h2>
GitHub repository
</h2>
<p>
Is <a href="https://github.com/simon-brooke/geocsv-js">here.</a>
</p>
</div>
</div>
<footer>
@ -181,10 +187,10 @@ crossorigin=""></script>
<script src="js/geocsv.js" type="text/javascript"></script>
<script>
/* Map using data from element content */
GeoCSV.initialise_map_element("element-content-map",
GeoCSV.initialiseMapElement("element-content-map",
document.getElementById("element-content-map").innerText);
/* Map using inline CSV passed to the function */
GeoCSV.initialise_map_element("inline-csv-map",
GeoCSV.initialiseMapElement("inline-csv-map",
"Country,Name,Latitude,Longitude,CountryCode,Continent,Category\n" +
"Somaliland,Hargeisa,9.55,44.05,NULL,Africa,\n" +
"Western Sahara,El-Aaiún,27.153611,-13.203333,EH,Africa,EH\n" +
@ -245,8 +251,16 @@ crossorigin=""></script>
"Zimbabwe,Harare,-17.8166666666667,31.033333,ZW,Africa,ZW\n" +
"British Indian Ocean Territory,Diego Garcia,-7.3,72.4,IO,Africa,\n" );
/* Map using CSV from URL */
var url = window.location.href.substring(0, window.location.href.length - "index.html".length) + "data/europe-capitals.csv";
GeoCSV.initialise_map_element("url-map", url);
console.log( "Window.location.href = `" + window.location.href + "`");
var url = window.location.href;
if (url.endsWith( "index.html")) {
url = url.substring(0, window.location.href.length - "index.html".length);
}
url = url + "data/europe-capitals.csv";
GeoCSV.initialiseMapElement("url-map", url);
</script>
</body>
</html>