Last active
April 14, 2017 10:16
-
-
Save Astro-Otter-Space/78f9292309798dbb693176d5de4235c6 to your computer and use it in GitHub Desktop.
Exemple OL
This file contains hidden or 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
var openlayers = require('openlayers'); | |
var moduleCarto = (function(ol) { | |
var initMap = function() | |
{ | |
// Couche Open Street map | |
var layerOsm = new ol.layer.Tile({ | |
title: 'Open Street Map', | |
visible: true, | |
type: 'overlays', | |
source: new ol.source.OSM() | |
}); | |
// Create view | |
var defCoordinates = getDefaultCorrdinates(); | |
var view = new ol.View({ | |
zoom: 10, | |
center: new ol.geom.Point(defCoordinates).transform('EPSG:4326', 'EPSG:3857').getCoordinates() | |
}); | |
var map = new ol.Map({ | |
layers: [layerOsm], | |
target: 'map', // ID du div HTML contenant ta carte | |
view: view | |
}); | |
return map; | |
}; | |
/** | |
* Return default coordinates WGS84 (cf GPS) | |
*/ | |
var getDefaultCorrdinates = function() | |
{ | |
return [2.352222, 48.856614] | |
} | |
return { | |
initMap: initMap | |
}; | |
})(openlayers); | |
moduleCarto.initMap(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment