0

我已经安装了 WP Photoswipe 并且最近刚刚安装了 WP Google Maps。

当我禁用 Photoswipe 插件时,地图会显示,当我重新启用它时,我在控制台上收到以下错误:

未捕获的类型错误:无法在第 600 行调用 null(匿名函数)的方法“setCenter”

我也从 Photoswipe 中得到这个错误:Uncaught Code.PhotoSwipe.createInstance: No images to pass。

这是来自 WP Google Maps 的代码:

<script type="text/javascript">
        if (typeof google === 'object' && typeof google.maps === 'object') { } else {
            var gmapsJsHost = (("https:" == document.location.protocol) ? "https://" : "http://");
            document.write(unescape("%3Cscript src='" + gmapsJsHost + "maps.google.com/maps/api/js?sensor=false' type='text/javascript'%3E%3C/script%3E"));
        }
    </script>
    <script type="text/javascript" >

        if ('undefined' == typeof window.jQuery) {
            document.getElementById('wpgmza_map').innerHTML = 'Error: In order for WP Google Maps to work, jQuery must be installed. A check was done and jQuery was not present. Please see the <a href="http://www.wpgmaps.com/documentation/troubleshooting/jquery-troubleshooting/" title="WP Google Maps - jQuery Troubleshooting">jQuery troubleshooting section of our site</a> for more information.';
        } else {
            // all good.. continue...
        }

        jQuery(function() {


            jQuery(document).ready(function(){
                if (/1\.(0|1|2|3|4|5|6|7)\.(0|1|2|3|4|5|6|7|8|9)/.test(jQuery.fn.jquery)) {
                    document.getElementById('wpgmza_map').innerHTML = 'Error: Your version of jQuery is outdated. WP Google Maps requires jQuery version 1.7+ to function correctly. Go to Maps->Settings and check the box that allows you to over-ride your current jQuery to try eliminate this problem.';
                } else {

                    jQuery("#wpgmza_map").css({
                        height:'500px',
                        width:'800px'
                    });
                    var myLatLng = new google.maps.LatLng(9.538973,-84.515788);
                    MYMAP.init('#wpgmza_map', myLatLng, 13);
                    UniqueCode=Math.round(Math.random()*10000);
                    MYMAP.placeMarkers('http://www.playasirenaresort.com/wp-content/plugins/wp-google-maps/1markers.xml?u='+UniqueCode,1);

                    jQuery('body').on('tabsshow', function(event, ui) {
                        MYMAP.init('#wpgmza_map', myLatLng, 13);
                        UniqueCode=Math.round(Math.random()*10000);
                        MYMAP.placeMarkers('http://www.playasirenaresort.com/wp-content/plugins/wp-google-maps/1markers.xml?u='+UniqueCode,1);
                    });
                }

            });

        });


        var MYMAP = {
            map: null,
            bounds: null
        }

        MYMAP.init = function(selector, latLng, zoom) {
            var myOptions = {
                zoom:zoom,
                center: latLng,
                zoomControl: true,
                panControl: true,
                mapTypeControl: true,
                streetViewControl: true,
                mapTypeId: google.maps.MapTypeId.SATELLITE                }

            this.map = new google.maps.Map(jQuery(selector)[0], myOptions);
            this.bounds = new google.maps.LatLngBounds();
            google.maps.event.addListener(MYMAP.map, 'click', function() {
                infoWindow.close();
            });
        }

        var infoWindow = new google.maps.InfoWindow();
                    infoWindow.setOptions({maxWidth:200});

        google.maps.event.addDomListener(window, 'resize', function() {
            var myLatLng = new google.maps.LatLng(9.538973,-84.515788);
            MYMAP.map.setCenter(myLatLng);
        });
        MYMAP.placeMarkers = function(filename,map_id) {

            jQuery.get(filename, function(xml){
                jQuery(xml).find("marker").each(function(){
                    var wpmgza_map_id = jQuery(this).find('map_id').text();

                    if (wpmgza_map_id == map_id) {
                        var wpmgza_address = jQuery(this).find('address').text();
                        var lat = jQuery(this).find('lat').text();
                        var lng = jQuery(this).find('lng').text();

                        var point = new google.maps.LatLng(parseFloat(lat),parseFloat(lng));
                        MYMAP.bounds.extend(point);
                        var marker = new google.maps.Marker({
                            position: point,
                            map: MYMAP.map
                        });
                        var html=''+wpmgza_address+'';

                        google.maps.event.addListener(marker, 'click', function(evt) {
                            infoWindow.close();
                            infoWindow.setContent(html);
                            infoWindow.open(MYMAP.map, marker);
                            //MYMAP.map.setCenter(this.position);
                        });
                    }
                });

            });
        }



    </script>

这是photoswipe网站http://www.photoswipe.com/可以访问js代码,这里太长了。这是wordpress插件:http ://wordpress.org/plugins/wp-google-maps/

希望有人可以帮助我,谢谢。

4

0 回答 0