-
-
Save garyhow01/759d8dfbca05aa46b2ea26bd13c35ed0 to your computer and use it in GitHub Desktop.
onemap.sg on Openlayers v3 & LeafletJS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.5/leaflet.css" /> | |
<style> | |
#map { width:640px; height:480px; } | |
</style> | |
<script src="http://cdn.leafletjs.com/leaflet-0.7.5/leaflet.js"></script> | |
<div id="map"></div> | |
<script type="text/javascript"> | |
var basemap; | |
var center = [1.355,103.840]; | |
var map2015 = L.tileLayer('http://e1.onemap.sg/arcgis/rest/services/SM256WGS84/MapServer/tile/{z}/{y}/{x}'); | |
var basemap = L.map('map', { | |
center: center, | |
zoom: 15, | |
minZoom: 12, | |
maxZoom: 18, | |
//fullscreenControl: true, | |
layers: [map2015] | |
}); | |
basemap.attributionControl.setPrefix('<a href="http://www.onemap.sg" target="_blank">www.onemap.sg</a>'); | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"> | |
<meta name="apple-mobile-web-app-capable" content="yes"> | |
<link rel="stylesheet" href="http://openlayers.org/en/v3.9.0/css/ol.css" type="text/css"> | |
<script src="http://openlayers.org/en/v3.9.0/build/ol.js" type="text/javascript"></script> | |
<script type="text/javascript"> | |
function init(){ | |
var mousePositionControl = new ol.control.MousePosition({ | |
coordinateFormat: ol.coordinate.createStringXY(4), | |
projection: 'EPSG:4326', | |
// comment the following two lines to have the mouse position be placed within the map. | |
//className: 'custom-mouse-position', | |
//target: document.getElementById('mouse-position'), | |
undefinedHTML: ' ' | |
}); | |
var urlx = 'http://e1.onemap.sg/arcgis/rest/services/SM256WGS84/MapServer/tile/{z}/{y}/{x}'; | |
var map = new ol.Map({ | |
controls: ol.control.defaults({ | |
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({ | |
collapsible: false | |
}) | |
}).extend([mousePositionControl]), | |
target: 'map', | |
layers: [ | |
new ol.layer.Tile({ | |
source: new ol.source.XYZ({ | |
url: urlx | |
}) | |
}) | |
], | |
view: new ol.View({ | |
center: ol.proj.fromLonLat([103.840, 1.355]), | |
zoom: 15 | |
}) | |
}); | |
} | |
</script> | |
</head> | |
<body onload="init()"> | |
<div id="map" class="smallmap"> | |
</div> | |
<div class="span6" id="mouse-position"> </div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment