Skip to content

Instantly share code, notes, and snippets.

@iamgeoknight
Last active February 6, 2021 11:30
Show Gist options
  • Select an option

  • Save iamgeoknight/abb8b680fcccdbdf2964a81b1c20fb63 to your computer and use it in GitHub Desktop.

Select an option

Save iamgeoknight/abb8b680fcccdbdf2964a81b1c20fb63 to your computer and use it in GitHub Desktop.
/*
Create and Render map on div with zoom and center
*/
class OLMap {
//Constructor accepts html div id, zoom level and center coordinaes
constructor(map_div, zoom, center) {
this.map = new ol.Map({
target: map_div,
layers: [
new ol.layer.Tile({
source: new ol.source.OSM()
})
],
view: new ol.View({
center: ol.proj.fromLonLat(center),
zoom: zoom
})
});
}
}
let map = new OLMap('map', 9, [-96.6345990807462, 32.81890764151014]).map;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment