Guest User

Untitled

a guest
Jan 21st, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.28 KB | None | 0 0
  1. google.maps.event.addListener(marker, 'click', function() {
  2. infowindow.setContent(contentString);
  3. infowindow.open(map,marker);
  4. });
  5.  
  6. google.maps.event.addListener(marker, 'click', function() {
  7. infowindow.setContent(contentString);
  8. $("#sidebar a").css('background-color','');//remove sidebar links back colors
  9. sidebarlink = $("#sidebar a:contains('"+marker.mydescription+"')");
  10. sidebarlink.css('background-color','#58FAD0');
  11. infowindow.open(map,marker);
  12. });
  13.  
  14. google.maps.event.addListener(map, 'click', function() {
  15. infowindow.close();
  16. });
  17.  
  18. google.maps.event.addListener(map, 'click', function() {
  19. $("#sidebar a").css('background-color','');//remove sidebar links back colors
  20. infowindow.close();
  21. });
  22.  
  23. #sidebar a:hover{
  24. background-color: #58FAD0;
  25. }​
  26.  
  27. makeMarker(options);
  28.  
  29. makeMarker({
  30. position: new google.maps.LatLng(60.17295,24.93981),
  31. content: "Some text into the info bubble.",
  32. sidebarItem: "Label text",
  33. });
  34.  
  35. the string to be shown (html tags allowed)
  36.  
  37. CSS className, default "sidebar_item"
  38.  
  39. width, default "120px"
  40.  
  41. /**
  42. * makeMarker() ver 0.2
  43. * creates Marker and InfoWindow on a Map() named 'map'
  44. * creates sidebar row in a DIV 'sidebar'
  45. * saves marker to markerArray and markerBounds
  46. * @param options object for Marker, InfoWindow and SidebarItem
  47. * @author Esa 2009
  48. */
  49. var infoWindow = new google.maps.InfoWindow();
  50. var markerBounds = new google.maps.LatLngBounds();
  51. var markerArray = [];
  52.  
  53. function makeMarker(options){
  54. var pushPin = new google.maps.Marker({map:map});
  55. pushPin.setOptions(options);
  56. google.maps.event.addListener(pushPin, "click", function(){
  57. infoWindow.setOptions(options);
  58. infoWindow.open(map, pushPin);
  59. if(this.sidebarButton)this.sidebarButton.button.focus();
  60. });
  61. var idleIcon = pushPin.getIcon();
  62. if(options.sidebarItem){
  63. pushPin.sidebarButton = new SidebarItem(pushPin, options);
  64. pushPin.sidebarButton.addIn("sidebar");
  65. }
  66. markerBounds.extend(options.position);
  67. markerArray.push(pushPin);
  68. return pushPin;
  69. }
  70.  
  71. google.maps.event.addListener(map, "click", function(){
  72. infoWindow.close();
  73. });
  74.  
  75.  
  76. /**
  77. * Creates a sidebar item
  78. * @constructor
  79. * @author Esa 2009
  80. * @param marker
  81. * @param options object Supported properties: sidebarItem, sidebarItemClassName, sidebarItemWidth,
  82. */
  83. function SidebarItem(marker, opts){
  84. var tag = opts.sidebarItemType || "button";
  85. var row = document.createElement(tag);
  86. row.innerHTML = opts.sidebarItem;
  87. row.className = opts.sidebarItemClassName || "sidebar_item";
  88. row.style.display = "block";
  89. row.style.width = opts.sidebarItemWidth || "120px";
  90. row.onclick = function(){
  91. google.maps.event.trigger(marker, 'click');
  92. }
  93. row.onmouseover = function(){
  94. google.maps.event.trigger(marker, 'mouseover');
  95. }
  96. row.onmouseout = function(){
  97. google.maps.event.trigger(marker, 'mouseout');
  98. }
  99. this.button = row;
  100. }
  101. // adds a sidebar item to a
  102. SidebarItem.prototype.addIn = function(block){ if(block && block.nodeType == 1)this.div = block; else this.div = document.getElementById(block) || document.getElementById("sidebar") || document.getElementsByTagName("body")[0]; this.div.appendChild(this.button); } // deletes a sidebar item SidebarItem.prototype.remove = function(){ if(!this.div) return false; this.div.removeChild(this.button); return true; }
Add Comment
Please, Sign In to add comment