Skip to content

Instantly share code, notes, and snippets.

@ramiroaznar
Last active September 1, 2024 05:30
Show Gist options
  • Save ramiroaznar/3d519f00ca10218ad96c to your computer and use it in GitHub Desktop.
Save ramiroaznar/3d519f00ca10218ad96c to your computer and use it in GitHub Desktop.
How to add a Singapore basemap in Leaflet
<!DOCTYPE html>
<html>
<head>
<title>How to add a Singapore basemap in Leaflet</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<link rel="shortcut icon" href="http://cartodb.com/assets/favicon.ico" />
<link rel="stylesheet" href="http://libs.cartocdn.com/cartodb.js/v3/3.15/themes/css/cartodb.css" />
<script src="http://libs.cartocdn.com/cartodb.js/v3/3.15/cartodb.js"></script>
<style>
html, body,#map {
width:100%;
height:100%;
padding: 0;
margin: 0;
}
</style>
</head>
<body>
<div id='map'></div>
<script type="text/javascript">
function main() {
// declare map object
var map;
// center and zoom level
var options = {
center: [1.352083, 103.819836],
zoom: 14,
};
// give options to map object
var map = new L.Map('map', options);
// add basemap to map object
// for more info: http://repo.sgmap.xyz/map-api/index.html
L.tileLayer('http://{s}-tiles.sgmap.xyz/v2/Satellite_2015/{z}/{x}/{y}.png', {
attribution: 'Map data © contributors, <a href="http://SLA.gov.sg">Singapore Land Authority</a>'
}).addTo(map);
}
window.onload = main;
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment