无法在wordpress中读取null的属性'lat'

时间:2014-06-24 08:08:33

标签: javascript php

我正在使用WordPress主题Atlas进行上市。在这个主题中,页面有一个地图。 此主题中的所有内容都正常工作,只有地图上的列表图标才会出现。当我检查chrome中的元素时,会出现以下错误:Uncaught TypeError: Cannot read property 'lat' of null in maps.gstatic.com/intl/en_ALL/mapfiles/api-3/17/5/main.js:27 和地图是enter image description here

        map: {

            <?php if(get_field('disable_map_autofit','option')) { ?>

                latLng: [<?php the_field('custom_map_center','option');?>],
                //latLng = <?php echo 'new google.maps.LatLng(38.4413426,27.0769706)'; $zoomLevel = '11'; ?>,
                //latLng: [38.41885,27.12871999999993],

            <?php } ?>

            options: {

                "zoom": <?php echo '15'; /*if(get_field('adjust_zoom','option') !== '') { echo get_field('adjust_zoom','option'); } else { echo '18'; } */?>,

                "draggable": <?php if(get_field('is_draggable','option')) { echo "true"; } else { echo 'false'; } ?>,

                "mapTypeControl":<?php if(get_field('map_type_control','option')) { echo "true"; } else { echo 'false'; } ?>,

                "mapTypeId": google.maps.MapTypeId.<?php echo the_field('map_type_id','option');?>,

                "scrollwheel": <?php if(get_field('scrollwheel_control','option')) { echo "true"; } else { echo 'false'; } ?>,

                "panControl": true,

                "rotateControl": false,

                "scaleControl": true,

                "streetViewControl": <?php if(get_field('street_view_control','option')) { echo "true"; } else { echo 'false'; } ?>,

                "zoomControl": <?php if(get_field('zoom_control','option')) { echo "true"; } else { echo 'false'; } ?>,

                "keyboardShortcuts": <?php if(get_field('keyboard_shortcuts','option')) { echo "true"; } else { echo 'false'; } ?>,

                "zoomControlOptions": {

                    <?php if(get_field('add_rtl_support','option')) { ?>

                        style: google.maps.ZoomControlStyle.DEFAULT

                    <?php } else { ?>

                        style: google.maps.ZoomControlStyle.SMALL

                    <?php } ?>

                }

            }

        },marker: {

            values: [

                    <?php $args = array( 'post_type' => 'listing', 'posts_per_page' => 900);

                        $listing_marker_loop = new WP_Query( $args );

                        while ( $listing_marker_loop->have_posts() ) : $listing_marker_loop->the_post(); 

                        $address = get_field('location');

                        global $post;

                        // load all 'categories' terms for the post

                        $terms = get_the_terms($post->ID, 'listings_categories');        

                        // we will use the first term to load ACF data from

                        if( !empty($terms) )

                        {

                            $term = array_pop($terms);

                            // Checking if listing is featured, if so load another marker image.

                            if(get_field("listing_is_featured")) {

                                $custom_marker = get_field('featured_marker', 'listings_categories_' . $term->term_id );

                            } else {

                                $custom_marker = get_field('marker_type', 'listings_categories_' . $term->term_id );

                            }

                        }



                        if(!empty($address['coordinates'])) {



                        ?>

                            {

                                latLng: [<?php echo $address['coordinates'];?> <?php if(get_field('multiple_marker_address','option')) { echo "+ (Math.random() -.5) / 1500"; } ?>],

                                    options: {

                                        <?php if($custom_marker !=='') { ?>

                                        icon: "<?php echo $custom_marker; ?>",

                                        <?php } else { ?>

                                        icon: "",

                                        <?php } ?>

                                        shadow: ""

                                    },

                                    data: '<div class="marker-wrapper <?php if(get_field("listing_is_featured")) { echo "featured-listing";} ?> animated fadeInDown"><div class="marker-title"> <a href="<?php the_permalink();?>"><?php $term_list = wp_get_post_terms($post->ID, 'listings_categories', array("fields" => "names")); echo "Gözlem Konusu : " .implode(",",$term_list);//the_title(); ?></a> </div><div class="marker-content"> <?php get_template_part( "includes/popup", "content" );?> <?php get_template_part( "includes/popup", "image" );?> <div class="clearboth"></div> <div class="close"><span class="icon-cancel"></span></div></div><span class="icon-down-dir"></span></div>'

                                }<?php if ($listing_marker_loop->current_post +1 == $listing_marker_loop->post_count) { ?><?php } else {echo',';} ?>



                        <?php } ?>



                    <?php endwhile; ?>



            ],





            cluster:{

                radius: 20,

                // This style will be used for clusters with more than 0 markers

                0: {

                    content: "<div class='cluster cluster-1 dp-button medium'>CLUSTER_COUNT</div>",

                    width: 90,

                    height: 80

                },

                // This style will be used for clusters with more than 20 markers

                20: {

                    content: "<div class='cluster cluster-2 dp-button medium'>CLUSTER_COUNT</div>",

                    width: 90,

                    height: 80

                },

                // This style will be used for clusters with more than 50 markers

                50: {

                    content: "<div class='cluster cluster-3 dp-button medium'>CLUSTER_COUNT</div>",

                    width: 90,

                    height: 80

                },

                events: {

                    click: function(cluster) {

                        map.panTo(cluster.main.getPosition());

                        map.setZoom(map.getZoom() + 2);

                    }

                }

            },

            events: {

                click: function(marker, event, context){

                    map.panTo(marker.getPosition());



                    infobox.setContent(context.data);

                    infobox.open(map,marker);



                }

            }

        },

通过这段代码,latLng即将到来。但是这个latLng上的图标不会出现 请帮帮我。谢谢。

0 个答案:

没有答案