如何修复Photoswipe所以它不会破坏Wordpress上的WP Google Maps插件?

时间:2013-09-22 03:43:43

标签: wordpress-plugin photoswipe

我已经安装了WP Photoswipe,最近刚安装了WP Google地图。

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

未捕获的TypeError:无法调用null的方法'setCenter' (600号匿名函数)

我也从Photoswipe收到此错误: 未捕获的Code.PhotoSwipe.createInstance:没有要传递的图像。

这是来自WP Google地图的代码:

<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>

这是photoswipes网站http://www.photoswipe.com/,您可以在其中访问js代码,此处发布时间过长。 这是wordpress插件:http://wordpress.org/plugins/wp-google-maps/

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

0 个答案:

没有答案