Skip to content

Instantly share code, notes, and snippets.

@nickdos
Last active September 2, 2020 01:10
Show Gist options
  • Save nickdos/0dc5f59702d01d661f26b9b1098ed747 to your computer and use it in GitHub Desktop.
Save nickdos/0dc5f59702d01d661f26b9b1098ed747 to your computer and use it in GitHub Desktop.
Demo ALA map
license: apache-2.0
height: 800
<!DOCTYPE html>
<html>
<head>
<title>LeafletJS and ALA occurrence layer</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.3.3/leaflet.css" />
</head>
<body>
<div id="map" style="height: 800px"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.3.3/leaflet.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
//add an occurrence layer for Calyptorhynchus
var calyptorhynchus = L.tileLayer.wms("https://biocache-ws-test.ala.org.au/ws/ogc/wms/reflect?q=genus:Pogona", {
LAYERS: 'ALA:occurrences',
FORMAT: 'image/png',
TRANSPARENT: true,
ATTRIBUTION: "Atlas of Living Australia",
BGCOLOR:"0x000000",
OUTLINE:"false",
ENV: "color:5574a6;name:circle;size:4;opacity:1"
});
//add an occurrence layer for acacia acuminata
var acacia = L.tileLayer.wms("https://biocache-ws-test.ala.org.au/ws/ogc/wms/reflect?q=genus:Acacia", {
LAYERS: 'ALA:occurrences',
FORMAT: 'image/png',
TRANSPARENT: true,
ATTRIBUTION: "Atlas of Living Australia",
BGCOLOR:"0x000000",
OUTLINE:"false",
ENV: "color:FF9900;name:circle;size:4;opacity:1"
});
var speciesLayers = new L.LayerGroup();
calyptorhynchus.addTo(speciesLayers);
acacia.addTo(speciesLayers);
var map = L.map('map', {
center: [-23.6,133.6],
zoom: 4,
scrollWheelZoom: false,
layers: [speciesLayers]
});
var streetView = L.tileLayer('https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png', {
maxZoom: 18,
attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' +
'<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
'Imagery © <a href="http://cartodb.com/attributions">CartoDB</a>',
id: 'examples.map-i875mjb7'
}).addTo(map);
var baseLayers = {
"Street": streetView
};
var overlays = {
"Calyptorhynchus": calyptorhynchus,
"Acacia acuminata": acacia
};
L.control.layers(baseLayers, overlays).addTo(map);
map.on('click', onMapClick);
function onMapClick(e) {
$.ajax({
url: "https://biocache.ala.org.au/ws/occurrences/info",
jsonp: "callback",
dataType: "jsonp",
data: {
q: "genus:Calyptorhynchus OR Acacia+acuminata",
zoom: "6",
lat: e.latlng.lat,
lon: e.latlng.lng,
radius:20,
format: "json"
},
success: function( response ) {
var popup = L.popup()
.setLatLng(e.latlng)
.setContent("<h3>Test</h3>Occurrences at this point: " + response.count)
.openOn(map);
}
});
}
</script>
</body>
</html>
@nickdos
Copy link
Author

nickdos commented Jul 27, 2020

I fixed this with by pointing to our test system, which fixed a bug related to params being sent in lowercase vs uppercase.

see http://bl.ocks.org/nickdos/0dc5f59702d01d661f26b9b1098ed747

Should be pushed to prod server in a week or two.

@BushRenegade
Copy link

is there a way to call the species via an id number or hash i have noticed the calls via names has some issues and given the ala seems to behind on keeping up with naming there are issues around getting the correct species.

@nickdos
Copy link
Author

nickdos commented Sep 2, 2020

Yes, you can search on species ID, however the service does lookup that separate service on-the-fly as well. E.g.

https://bie.ala.org.au/ws/search?q=Dwarf%2BBearded%2BDragon

returns a guid of urn:lsid:biodiversity.org.au:afd.taxon:f777ebe8-250f-4b8e-9e25-b5944a2ea023, which can be searched via

https://biocache.ala.org.au/ws/occurrences/search?q=lsid:urn:lsid:biodiversity.org.au:afd.taxon:f777ebe8-250f-4b8e-9e25-b5944a2ea023

Same params can be used with /ws/mapping/wms/reflect.

Note the GUID can NOT be relied on to be permanent, due to the fact that taxonomy revisions sometimes result in "splits" or "joins" and the GUIDs then change.

All APIs are listed here: https://api.ala.org.au.

@BushRenegade
Copy link

Thanks @nickdos this is not working on the production server, works if i set it to the test server

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment