Skip to content

Instantly share code, notes, and snippets.

var map = new L.Map('map', {
crs: L.CRS.proj4js('EPSG:3994', '+proj=merc +lon_0=100 +lat_ts=-41 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs', new L.Transformation(1, -4200000, -1, -2000000)),
scale: function(zoom) {
return 1 / (16000 / Math.pow(2, zoom));
},
layers: [
new L.TileLayer('tiles/nz-seafloor/{z}/{x}/{y}.png', {
attribution: 'Data from <a href="http://www.niwa.co.nz/our-science/oceans/bathymetry">NIWA</a> and <a href="http://data.linz.govt.nz/">LINZ</a>',
minZoom: 0,
maxZoom: 6,
<Map srs="+proj=merc +lon_0=100 +lat_ts=-41 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs">
<Style name="color relief style">
<Rule>
<RasterSymbolizer mode="normal" />
</Rule>
</Style>
<Style name="hillshade style">
<Rule>
<RasterSymbolizer opacity="0.3" mode="multiply" scaling="bilinear" />
0 110 220 110
900 240 250 160
1300 230 220 170
1900 220 220 220
2500 250 250 250
<Map srs="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over">
<Style name="hillshade style">
<Rule>
<RasterSymbolizer scaling="bilinear" />
</Rule>
</Style>
<Style name="slopeshade style">
<Rule>
<RasterSymbolizer scaling="bilinear" mode="screen" />
@water: #96cfe6;
@ice: #fff;
@shingle: #ccc;
@sand: #f1dfaa;
@swamp: #749039;
@mangrove: #79b779;
@exotic: #53a550;
@native: #39af34;
@mud: #bfb69b;
@residental: #fed700;
var seafloor = L.tileLayer('tiles/nz-seafloor/{z}/{x}/{y}.png', {
maxZoom: 9,
attribution: 'Map data from <a href="http://www.niwa.co.nz/our-science/oceans/bathymetry">NIWA</a>'
});
var topo = L.tileLayer('tiles/nz-topo/{z}/{x}/{y}.png', {
attribution: '<a href="http://data.linz.govt.nz/">LINZ</a>, <a href="http://lris.scinfo.org.nz/">LRIS</a>'
});
var map = new L.Map('map', {
L.CartoDB = L.GeoJSON.extend({
initialize: function (url, options) {
L.Util.setOptions(this, options);
this._layers = {};
var self = this;
if (url) {
this._jsonp(url, function(geojson){
L.cartoDB('http://thematicmapping.cartodb.com/api/v2/sql?q=SELECT * FROM nz_tour', {
pointToLayer: function(feature, latlng) {
return L.marker(latlng, {
icon: L.icon({
iconSize: [27, 27],
iconAnchor: [13, 27],
popupAnchor: [1, -24],
iconUrl: 'icons/' + feature.properties.icon + '.png'
})
})
// Create map layers
var layers = {
'Seafloor': L.tileLayer('tiles/nz-seafloor/{z}/{x}/{y}.png', {
maxZoom: 9,
attribution: '<a href="http://www.niwa.co.nz/our-science/oceans/bathymetry">NIWA</a>'
}),
'Topographic': L.tileLayer('tiles/nz-topo/{z}/{x}/{y}.png', {
attribution: '<a href="http://data.linz.govt.nz/">LINZ</a>, <a href="http://lris.scinfo.org.nz/">LRIS</a>'
}),
L.geoJson(springs, {
pointToLayer: function (feature, latlng) {
return L.circleMarker(latlng, {
fillColor: (feature.properties.temp === 'hot') ? '#f00' : '#00f',
radius: 4,
color: "#333",
weight: 1,
fillOpacity: 1
});
},