Skip to content

Instantly share code, notes, and snippets.

@pgiraud
Last active August 29, 2015 13:56
Show Gist options
  • Select an option

  • Save pgiraud/9267889 to your computer and use it in GitHub Desktop.

Select an option

Save pgiraud/9267889 to your computer and use it in GitHub Desktop.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
<title>Mobile full screen example</title>
<style type="text/css">
html, body, .map {
margin: 0;
padding: 0;
width: 800px;
height: 600px;
}
</style>
<link href="http://ol3js.org/en/master/css/ol.css" rel='stylesheet' type='text/css' />
</head>
<body>
<div id="map" class="map"></div>
<img id="geolocation_marker" src="geolocation_marker.png" />
<script src="http://ol3js.org/en/master/build/ol.js" type="text/javascript"></script>
<script>
var view = new ol.View2D({
center: ol.proj.transform([20, 53], 'EPSG:4326', 'EPSG:3857'),
zoom: 4
});
var map = new ol.Map({
layers: [
new ol.layer.Tile({
source: new ol.source.OSM()
})
],
target: 'map',
view: view
});
var london = ol.proj.transform([-0.12755, 51.507222], 'EPSG:4326', 'EPSG:3857');
var moscow = ol.proj.transform([37.6178, 55.7517], 'EPSG:4326', 'EPSG:3857');
var markerEl = document.getElementById('geolocation_marker');
var marker = new ol.Overlay({
positioning: 'center-center',
element: markerEl,
stopEvent: false
});
map.addOverlay(marker);
marker.setPosition(london);
window.setTimeout(function() {
marker.setPosition(moscow);
}, 2000);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment