i have created following method adding markers 2 google map. these results dynamic , created whenever map moved.
function addmarker2(lat, lng, hid, label, map) { var price = label; if (price == null) price = "0.00" var marker = new richmarker({ position: new google.maps.latlng(lat, lng), map: map, draggable: false, flat: true, //anchor: richmarkerposition.middle, content: '<div data-hid="' + hid + '" class="map-tooltip">' + price + ' </div>', id: hid }); markers.push(marker); marker.addlistener('click', function () { //marker.addlistener('click', function (e) { // stop event bubbling map click event //e = e || window.event; //var e = window.event || e; event.preventdefault(); // close open infoboxes if (infowindow != null) infowindow.close(); // find clicked hotel var hotel; $.each(hotel_json, function (i, obj) { if (obj.hid === hid) { hotel = obj; } }); // build infobox html var contentstring = '<img src="' + hotel.img + '" alt="" style="height: 150px; width: 100%"><a class="favourite-button toggle-select" id="favourite-button"><i class="fa fa-heart-o fa-2x"></i></a><h5><span style="text-overflow: ellipsis; overflow: hidden; white-space: nowrap;"><a href="javascript:;" style="text-decoration: none; color: #888">' + hotel.name + '</a></span><br /><div class="mt5 text-warning-custom"><i class="fa fa-star"></i><i class="fa fa-star"></i><i class="fa fa-star"></i></div></h5><span>guesthouse</span><p class="text-primary"><sup class="h6 pr5">r</sup><span class="h3">' + hotel.price + '</span><sup class="h6 pl5">zar</sup></p><div class="map-action-btns"><a href="javascript:;" class="btn btn-sm btn-info btn-block"><i class="fa fa-file"></i> request quote</a><a href="javascript:;" class="btn btn-sm btn-success btn-block"><i class="fa fa-calendar-o"></i> book now</a></div>'; // open infobox infowindow = new google.maps.infowindow({ content: contentstring, maxwidth: 200 }); infowindow.open(map, marker); }); }
if click on custom marker additional information gets displayed. problem comes in event.preventdefault() works fine on chrome , ie. have tried multiple solutions online , has had no success. missing simple. appreciated. have left of things have tried in comments.
Comments
Post a Comment