Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Below is the code:
function map_init() {
Qva.AddExtension("GoogleMaps - Marker",function() {
var _this = this;
var divName = _this.Layout.ObjectId.replace("\\", "_");
var map_canvas = document.getElementById('map_canvas');
if (_this.Element.children.length == 0) {
var ui = document.createElement("div");
ui.setAttribute("id", divName);
_this.Element.appendChild(ui);
$("#" + divName).css("height", _this.GetHeight() + "px").css("width", _this.GetWidth() + "px");
} else {
$("#" + divName).css("height", _this.GetHeight() + "px").css("width", _this.GetWidth() + "px");
$("#" + divName).empty();
};
var latlngbounds = new google.maps.LatLngBounds();
var map = new google.maps.Map(document.getElementById(divName,map_canvas), {
mapTypeId: google.maps.MapTypeId.ROADMAP
});
for (var i=0,k=_this.Data.Rows.length;i<k;i++){
var row = _this.Data.Rows ;
var latLng = new google.maps.LatLng(row[0].text,row[1].text);
var marker = new google.maps.Marker({position: latLng, title: row[2].text, map: map});
latlngbounds.extend(latLng);
google.maps.event.addListener(marker, 'click', (function(value) { return function() { _this.Data.SelectRow(value) }})(i))
});
};
map.setCenter(latlngbounds.getCenter());
map.fitBounds(latlngbounds);
});
};
/* load external libs - callback map_init() */
loadLibs();
function loadLibs() {
Qva.LoadScript('https://maps.google.com/maps/api/js?sensor=false&callback=map_init')
};