Google Maps Marker Shadow未显示

时间:2013-09-25 09:36:40

标签: javascript wordpress google-maps google-maps-api-3

所以在wordpress中有一组图像可以拉入,但我想添加一个png,它将充当它们的阴影。它目前没有为我的标记添加阴影。

以下是我的代码。有谁看到这个bug?地图工作正常,刚刚添加阴影

<?php
get_header();
get_template_part('ts-themes/whatspecies/header-whatspecies');
?>

<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
<script>
jQuery(document).ready(function () {
var LocationData = [
    <?php

    $args = array(
        'post_type' => 'post',
        'posts_per_page' => 200
    );

    $the_query = new WP_Query( $args );
    if ( $the_query->have_posts() ) :
        $a=0;
        while ( $the_query->have_posts() ) : $the_query->the_post();
            $location = get_post_meta(get_the_id(),'location',true);
            if(!empty($location)){
                $lat = $location['map_lat'];
                $long = $location['map_long'];
                $cat =get_the_category( get_the_ID() );
                $icon = site_url().'/wp-content/themes/themesmith/ts-themes/whatspecies/icons/map/'.$cat[0]->category_nicename.'.png';

                echo '['.$lat.','.$long.',"<a href='.get_permalink().'>'.get_the_title().'</a>","'.$icon.'"],';
            }

        endwhile;
        wp_reset_query();
    endif;
    ?>
];
var map =
new google.maps.Map(document.getElementById('map-canvas'));
var bounds = new google.maps.LatLngBounds();
var infowindow = new google.maps.InfoWindow();
var shadow = {
        url: 'http://whatspecies.beresponsive.net/wp-content/themes/themesmith/ts-themes/whatspecies/icons/map/marker-shadow.png',
         size: new google.maps.Size(64, 64),
         origin: new google.maps.Point(0,0),
         anchor: new google.maps.Point(0, 64)

    };
for (var i in LocationData)
{
    var p = LocationData[i];
    var latlng = new google.maps.LatLng(p[0], p[1]);
    bounds.extend(latlng);


    var marker = new google.maps.Marker({
        position: latlng,
        map: map,
        icon:p[3],
        title: p[2],
        shadow: shadow
    });

    google.maps.event.addListener(marker, 'click', function() {
        infowindow.setContent(this.title);
        infowindow.open(map, this);
    });
}

map.fitBounds(bounds);
});
</script>


<div class="body clearfix">
<div class="entries full-template">
    <div class="entry-holder entry-map page-holder">
        <div class="title">
            <h1>
                <span>Observations map</span>
            </h1>
            <div class="meta"></div>
        </div>
        <div class="content">
            <div class="the-content">
                    <div id="map-canvas"></div>
            </div>
        </div>
    </div>
</div>
</div>

<?php get_template_part('ts-themes/whatspecies/footer-whatspecies') ?>

<?php get_footer();

1 个答案:

答案 0 :(得分:1)

Google Maps JavaScript API 3.14版不再支持标记阴影。

以下内容来自https://developers.google.com/maps/documentation/javascript/markers

  

注意:Google Maps JavaScript API 3.14版中删除了标记阴影。以编程方式指定的任何阴影都将被忽略。