Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. var raster = new ol.layer.Tile({
  2. source: new ol.source.OSM()
  3. });
  4.  
  5. var map = new ol.Map({
  6. layers: [raster],
  7. target: 'map',
  8. view: new ol.View({
  9. resolutions : customRes,
  10. center: [-11000000, 4600000],
  11. resolution : 156543.0339
  12. })
  13. });
  14.  
  15. /**
  16. * get the resolution out of scale
  17. * @param {number} scale as declared in the config eg 50000
  18. * @returns {window.webGisApp.main.resolutions}
  19. */
  20. function getResolutionFromScale(scale){
  21. var dpi = 25.4 / 0.28;
  22. var mpu = ol.proj.METERS_PER_UNIT['m'];
  23. var res = scale / (mpu * 39.37 * dpi);
  24. return res;
  25. }
  26. /**
  27. * get the resolution out of scale
  28. * @param {number} res the resolution
  29. * @returns {webGisApp.main.resolutions}
  30. */
  31. function getScaleFromResolution(res){
  32. var dpi = 25.4 / 0.28;
  33. var mpu = ol.proj.METERS_PER_UNIT['m'];
  34. var scale = res * mpu * 39.37 * dpi;
  35. return scale;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement