1

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

下面是我的代码。有没有人看到这个错误?地图工作正常,它刚刚添加了阴影

<?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();
4

1 回答 1

1

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

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

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

于 2015-06-14T17:58:23.890 回答