javascript - Google Maps API - Hover on markers and show image -


i trying google maps instance show bunch of markers, , when hover on specific marker change larger image. revert original marker image when mouse leaves new image area. seem have working i'd in jsfiddle:

https://jsfiddle.net/vn9po27c/2/

var locations_programs = [      ['christie lake camp', 44.803033, -76.418031, 1, 'http://www.christielakekids.com/_images/map_pins/events/canoe-for-kids.png', ''],          ['caldwell community centre', 45.373083, -75.735550, 1, 'http://www.christielakekids.com/_images/map_pins/events/caldwell-community-centre.png', ''],          ['dempsey community centre', 45.401887, -75.627530, 1, 'http://www.christielakekids.com/_images/map_pins/events/dempsey-community-centre.png', ''],          ['brewer arena', 45.389560, -75.691445, 1, 'http://www.christielakekids.com/_images/map_pins/events/brewer-arena.png', '']  ];  var markersarray = []; var markers = {}; var mapoptions = {        center: new google.maps.latlng(45.4214, -75.6919),       zoom: 10,       scrollwheel: true,       scalecontrol: true,       maptypeid: google.maps.maptypeid.roadmap,       zoomcontrol: true,       zoomcontroloptions: {           style: google.maps.zoomcontrolstyle.large,           position: google.maps.controlposition.right_top         },       pancontrol: true,           pancontroloptions: {           position: google.maps.controlposition.top_right         }     };   //***  programs      var marker, i;     var id = 'programs';      (i = 0; < locations_programs.length; i++) {         var id = 'programs' + i;        marker = new google.maps.marker({         position: new google.maps.latlng(locations_programs[i][1], locations_programs[i][2]),         map: map         ,id: id         ,icon: 'http://www.christielakekids.com/_images/new/blue_circle.png'         ,url: locations_programs[i][5]         ,zindex:100       });            google.maps.event.addlistener(marker, 'mouseover', function(event) {             this.seticon('http://www.christielakekids.com/_images/map_pins/events/canoe-for-kids.png');         });         google.maps.event.addlistener(marker, 'mouseout', function(event) {             this.seticon('http://www.christielakekids.com/_images/new/blue_circle.png');         });        } 

the problem using same code on beta website, , it's not working same. on website change not occur on mouseover / mouseout, rather onclick.

http://www.christielakekids.com/newsite/

it map showing under "where we're making difference".

try seem functioning

  <!doctype html>     <html>       <head>         <title>test sandbox 8</title>          <style type="text/css">           #main {             margin: 60px 15px;            }           #map {              min-height: 600px;              min-width: 800px;            }         </style>              <script src="http://maps.google.com/maps/api/js?v=3&sensor=false" type="text/javascript"></script>         <script>           // code draw map           var map;           var col = '#ff0000';           var link ;           var latlng;           var polypoints;            function initialize() { var locations_programs = [    ['christie lake camp', 44.803033, -76.418031, 1, 'http://www.christielakekids.com/_images/map_pins/events/canoe-for-kids.png', ''],        ['caldwell community centre', 45.373083, -75.735550, 1, 'http://www.christielakekids.com/_images/map_pins/events/caldwell-community-centre.png', ''],        ['dempsey community centre', 45.401887, -75.627530, 1, 'http://www.christielakekids.com/_images/map_pins/events/dempsey-community-centre.png', ''],        ['brewer arena', 45.389560, -75.691445, 1, 'http://www.christielakekids.com/_images/map_pins/events/brewer-arena.png', '']  ];  var markersarray = []; var markers = {}; var mapoptions = {      center: new google.maps.latlng(45.4214, -75.6919),     zoom: 10,     scrollwheel: true,     scalecontrol: true,     maptypeid: google.maps.maptypeid.roadmap,     zoomcontrol: true,     zoomcontroloptions: {         style: google.maps.zoomcontrolstyle.large,         position: google.maps.controlposition.right_top       },     pancontrol: true,         pancontroloptions: {         position: google.maps.controlposition.top_right       }   };    map = new google.maps.map(document.getelementbyid('map'),   mapoptions);    //***  programs    var marker, i;   var id = 'programs';    (i = 0; < locations_programs.length; i++) {       var id = 'programs' + i;      marker = new google.maps.marker({       position: new google.maps.latlng(locations_programs[i][1], locations_programs[i][2]),       map: map       ,id: id       ,icon: 'http://www.christielakekids.com/_images/new/blue_circle.png'       ,url: locations_programs[i][5]       ,zindex:100     });          google.maps.event.addlistener(marker, 'mouseover', function(event) {           this.seticon('http://www.christielakekids.com/_images/map_pins/events/canoe-for-kids.png');       });       google.maps.event.addlistener(marker, 'mouseout', function(event) {           this.seticon('http://www.christielakekids.com/_images/new/blue_circle.png');       });      } }   google.maps.event.adddomlistener(window, 'load', initialize);          </script>       </head>       <body>              <div id="map"></div>        </body>     </html> 

Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -