0

我有一个页面,它根据搜索结果加载带有标记的谷歌地图。搜索结果是串联的一些 div。当有人将鼠标悬停在 div 上时,我希望谷歌地图上的相应标记显示其信息窗口。这有可能吗?

我在下面提供了 jquery 代码。如果需要其他页面的任何代码,请告知

if (typeof SPGeoMapsModReg == 'undefined') {
    var SPGeoMapsModReg = {}
}
function SPGeoMapModInit(a, b) {
    jQuery(document).ready(function() {
        SPGeoMapsModReg[a] = new SPGeoMapMod(a).init(b)
    })
}
function SPGeoMapMod(h) {
    this.Options;
    this.Map;
    this.Position;
    this.Markers = [];
    this.cid = h + 'Inner';
    this.Container = jQuery('#' + h);
    this.Canvas = jQuery('#' + this.cid);
    this.InfoWindow;
    this.init = function(a) {
        this.Options = a;
        this.Container.css('width', a.mapWidth).css('height', a.mapHeight).css('background-color', 'black').css('background', 'url(media/sobipro/progress/ajax-loader.gif) center center no-repeat').fadeTo('slow', 0.2);
        this.getEntries();
        return this
    };
    this.getEntries = function() {
        var b = this;
        jQuery.ajax({
            url: 'index.php',
            type: 'POST',
            dataType: 'json',
            data: {
                'option': 'com_sobipro',
                'task': 'geomod.load',
                'sid': this.Options.sid,
                'format': 'raw',
                'section': this.Options.pid,
                'ctask': this.Options.task
            },
            success: function(a) {
                b.InitMap(a)
            }
        })
    };
    this.InitMap = function(a) {
        this.Position = new google.maps.LatLng(parseFloat(this.Options.startLatitude), parseFloat(this.Options.startLongitude));
        var b = [];
        for (i = 0; i < this.Options.availableViews.length; i++) {
            b[i] = google.maps.MapTypeId[String(this.Options.availableViews[i]).toUpperCase()]
        }
        var c = {
            zoom: parseFloat(this.Options.zoomLevel),
            mapTypeId: google.maps.MapTypeId[String(this.Options.defaultView).toLocaleUpperCase()]
        };
        for (var i in this.Options.mapOptions) {
            c[i] = this.Options.mapOptions[i]
        }
        if (b.length > 0) {
            c['mapTypeControlOptions'] = {
                mapTypeIds: b
            }
        }
        this.Canvas.css('width', this.Options.mapWidth).css('height', this.Options.mapHeight);
        this.Map = new google.maps.Map(document.getElementById(this.cid), c);
        this.Map.setCenter(this.Position);
        var d = this;
        for (var i = 0; i < a.entries.length; i++) {
            var e = new google.maps.LatLng(parseFloat(a.entries[i].latitude), parseFloat(a.entries[i].longitude));
            var f = new google.maps.Marker({
                'position': e
            });
            f.sid = a.entries[i].sid;
            google.maps.event.addListener(f, 'mouseover', function() {
                d.OpenInfo(this)
            });
            this.Markers.push(f)
        }

        var g = new MarkerClusterer(this.Map, this.Markers);
        this.Container.fadeTo('slow', 1).css('background', 'none');
        if (a.msg.length) {
            alert(a.msg)
        }
    };
    this.OpenInfo = function(b) {
        var c = this;
        try {
            this.InfoWindow.close()
        } catch (e) {}
        this.InfoWindow = new google.maps.InfoWindow();
        this.InfoWindow.setContent('<img src="media/sobipro/progress/ajax-loader.gif"/>');
        this.InfoWindow.open(this.Map, b);
        jQuery.ajax({
            url: 'index.php',
            type: 'POST',
            dataType: 'json',
            data: {
                'option': 'com_sobipro',
                'task': 'geomod.info',
                'sid': b.sid,
                'format': 'raw',
                'iid': c.Options.iid
            },
            success: function(a) {
                c.InfoWindow.setContent(a.html)
            }
        })
    }
}
4

0 回答 0