Advertisement
elbatron

Elevation Chart Toggle

Aug 10th, 2013
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.85 KB | None | 0 0
  1. function HomeControl(controlDiv, map) {
  2. // Set CSS styles for the DIV containing the control
  3. // Setting padding to 5 px will offset the control
  4. // from the edge of the map
  5. controlDiv.style.padding = '5px';
  6. // Set CSS for the control border
  7. var controlUI = document.createElement('div');
  8. controlUI.style.backgroundColor = 'white';
  9. controlUI.style.borderStyle = 'solid';
  10. controlUI.style.borderWidth = '1px';
  11. controlUI.style.cursor = 'pointer';
  12. controlUI.style.textAlign = 'center';
  13. controlUI.style.borderRadius = '2px';
  14. controlUI.style.borderColor = 'rgba(0, 0, 0, 0.2902)';
  15. controlUI.style.boxShadow = '0 1px 4px -1px rgba(0,0,0,0.298039)';
  16. //controlUI.style.hover = '#000';
  17.  
  18. controlUI.title = 'Click to see Elevation data';
  19. controlDiv.appendChild(controlUI);
  20. // Set CSS for the control interior
  21. var controlText = document.createElement('div');
  22. controlText.style.fontFamily = 'Roboto, sans-serif';
  23. controlText.style.fontSize = '11px';
  24. controlText.style.paddingTop = '5px';
  25. controlText.style.paddingBottom = '5px';
  26. controlText.style.paddingLeft = '6px';
  27. controlText.style.paddingRight = '6px';
  28. controlText.style.color = 'rgb(86, 86, 86)';
  29. controlText.innerHTML = 'Elevation';
  30. // controlText.id = "chartbtn";
  31.  
  32. controlUI.appendChild(controlText);
  33.  
  34. $('.plot').addClass('closed');
  35. $('#map_container').css('height', winHeight);
  36. $('#map_canvas').css('height', winHeight - 40 + 'px');
  37. $('#map_canvas').css('top','40px');
  38.  
  39.  
  40. google.maps.event.addDomListener(controlUI, 'mouseover', function(event) {
  41. controlText.style.fontWeight = '500';
  42. controlText.style.color = '#000';
  43. controlUI.style.backgroundColor = '#eee';
  44. });
  45. google.maps.event.addDomListener(controlUI, 'mouseout', function(event) {
  46. controlUI.style.backgroundColor = '#fff';
  47. controlText.style.fontWeight = '400';
  48. controlText.style.color = 'rgb(86, 86, 86)';
  49. });
  50.  
  51.  
  52. google.maps.event.addDomListener(controlUI, 'click', function(event) {
  53.  
  54. if( $('.plot').hasClass('open') ) {
  55. $('.plot').animate({"bottom" : "-190px"}, 200).removeClass('open').addClass('closed');;
  56. $('#map_canvas').height( winHeight - 40 + 'px');
  57. google.maps.event.trigger(map, 'resize');
  58. //map.panBy(0, -50);
  59. map.fitBounds(bounds);
  60. }
  61. else {
  62.  
  63. $('.plot').animate({"bottom" : "0px"}, 200).removeClass('closed').addClass('open');
  64. $('#map_canvas').height( winHeight - 230 + 'px');
  65. google.maps.event.trigger(map, 'resize');
  66. //map.panBy(0, 190);
  67. var newbounds = map.getBounds();
  68. map.fitBounds(newbounds);
  69. //map.panBy(0, 50);
  70.  
  71. }
  72. });
  73. }
  74.  
  75. var homeControlDiv = document.createElement('div');
  76. var homeControl = new HomeControl(homeControlDiv, map);
  77.  
  78. homeControlDiv.index = 1;
  79. map.controls[google.maps.ControlPosition.TOP_RIGHT].push(homeControlDiv);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement