Google Maps Api add multiple custom overlays in loop -


i try add multiple custom overlays googlemaps. @ first add 2 images, following code.

        var overlays = [];         var data = mappings[0];         var data2 = mappings[1];           usgsoverlay.prototype = new google.maps.overlayview();          var bounds = new google.maps.latlngbounds(             new google.maps.latlng(data.latnw, data.lngnw),             new google.maps.latlng(data.latse, data.lngse));          var bounds2 = new google.maps.latlngbounds(             new google.maps.latlng(data2.latnw, data2.lngnw),             new google.maps.latlng(data2.latse, data2.lngse));          // photograph courtesy of u.s. geological survey.         var srcimage = 'maps/' + data.name;         var srcimage2 = 'maps/' + data2.name;          // custom usgsoverlay object contains usgs image,         // bounds of image, , reference map.         overlays.push(new usgsoverlay(bounds, srcimage, map));         overlays.push(new usgsoverlay(bounds2, srcimage2, map)); 

that works fine.

after try add multiple images in loop.

        var overlays = [];         var bounds = [];         var srcimage = [];          usgsoverlay.prototype = new google.maps.overlayview();          (i = 0; < mappings.length; i++) {             var data = mappings[i];               bounds.push(google.maps.latlngbounds(                 new google.maps.latlng(data.latnw, data.lngnw),                 new google.maps.latlng(data.latse, data.lngse)));               // photograph courtesy of u.s. geological survey.             srcimage.push('maps/' + data.name);             // custom usgsoverlay object contains usgs image,             // bounds of image, , reference map.             overlays.push(new usgsoverlay(bounds[i], srcimage[i], map));         } 

now can't see image @ map , can't zoom. how can add multiple overlays in loop?


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -