如何在javascript中删除谷歌地图上的标记阴影?

时间:2012-11-09 05:16:49

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

我的谷歌地图上有一些标记,有些标记位于另一个标记的阴影下。阴影中的标记不起作用。如何删除阴影或任何其他解决方案。

提前致谢。

enter code here
 function createMarker(){
                    var s;
                        for (var i = 0, j=0; i < markers_array.length; i++, j++) {
    // obtain the attribues of each marker
                            var lat = parseFloat(markers_array[i][0]);
                            var lng = parseFloat(markers_array[i][1]);
                            //alert(markers_array[i][2]);
                            //alert(markers_array[i][3]);
                            var trailhead_name = markers_array[i][2];
                            var trailhead_name1 = markers_array[i][3];
                            var image = markers_array[i][4];

                            var myLatlng = new google.maps.LatLng(lat, lng);

                            var contentString = trailhead_name;
                            var contentString1= trailhead_name1;
                            var marker=[];
                             marker[i] = new google.maps.Marker({
                                position: myLatlng,
                                map: map,
                                icon: image,
                                clickable: true,
                                title:markers_array[i][5],

                                });
                            google.maps.event.addListener(map, 'click', function(e) {

                            infobox.close();
                            infobox1.close();
                            infobox2.close();

                            });


                            marker[i]['infowindow'] = contentString;
                            marker[i]['infowindow1']= contentString1;
                            global_markers[i] = marker[i];



                            var la;
                            var lt;
                            google.maps.event.addListener(global_markers[i], 'click', function(e) {
                            infobox.close();
                            infobox1.close();
                            infobox2.close(); 
                            la=this.getPosition().lat();
                            lt=this.getPosition().lng();
                                infobox.setPosition(e.latLng);
                                infobox.setContent(this['infowindow']);
                                infobox.boxStyle_ = {
                                        background: "url('images/tipbox.gif') no-repeat  scroll 0 0 #E1E3E4",

                                        width: "270px"
                                    };
                                infobox.open(map);
                                var title=this.title;
                                s=this['infowindow1'];
                                $(document).delegate("#content", "mouseenter touchstart", function() {
                                map.setOptions({
                                draggable: false,
                                scrollwheel: false
                                });




                                });

                            $(document).delegate("#content", "mouseleave touchend", function() {
                                map.setOptions({draggable: true,scrollwheel: true});


                            });
                            });
                            }

1 个答案:

答案 0 :(得分:1)

您需要为图标和阴影创建和使用MarkerImage类,然后在事件期间使用标记setIcon和setShadow方法将它们与放大版本交换。放大的MarkerImage类需要使用scaledSize属性。这会将图像拉伸到MarkerImage大小属性的大小

以下是此行动中的一个小提琴示例:check

var shadow = new google.maps.MarkerImage(
  beachflagShadowUrl,
  // The shadow image is larger in the horizontal dimension
  // while the position and offset are the same as for the main image.
  new google.maps.Size(37, 32),
  new google.maps.Point(0,0),
  new google.maps.Point(0, 32));

或检查this

 chst=d_map_pin_icon[_withshadow]
 chld=<icon_string>|<fill_color>

seethis