如何从google maps api中删除RichMarker阴影类?

时间:2015-04-13 12:44:08

标签: javascript google-maps marker

要在我的Google地图api中创建自己的<div>,我使用了RichMarker库,文档在这里:(link)和库:( link)。所以我的代码看起来像这样:

for(i = 0; i < location.length; i++){
    var loc = location[i];
    var coordinates = new google.maps.LatLng(loc[1], loc[2]);
    var marker = new RichMarker({
        position: coordinates,
        map: map,
        zIndex: coordinates[3],
        content: '<div class="myClass">TEXT</div>'
    });
}

现在上面的代码在我的div周围绘制了一个阴影(这不是我的css,它画了一个阴影,我猜这是来自RichMarker库的css)。这是一张图片:

enter image description here

我的问题是:如何删除此影子'

真的感谢您的帮助。

2 个答案:

答案 0 :(得分:10)

你试过了吗?

var marker = new RichMarker({
        position: coordinates,
        map: map,
        zIndex: coordinates[3],
        shadow: 'none',
        content: '<div class="myClass">TEXT</div>'
    });

答案 1 :(得分:1)

Per the documentation setShadow方法可让您更改阴影。

marker.setShadow("");

proof of concept fiddle

代码段:

var geocoder;
var map;
var locations = [
  ['Bondi Beach', -33.890542, 151.274856, 4],
  ['Coogee Beach', -33.923036, 151.259052, 5],
  ['Cronulla Beach', -34.028249, 151.157507, 3],
  ['Manly Beach', -33.80010128657071, 151.28747820854187, 2],
  ['Maroubra Beach', -33.950198, 151.259302, 1]
];

function initialize() {
  var map = new google.maps.Map(
    document.getElementById("map_canvas"), {
      center: new google.maps.LatLng(37.4419, -122.1419),
      zoom: 13,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    });
  var bounds = new google.maps.LatLngBounds();
  for (i = 0; i < locations.length; i++) {
    var loc = locations[i];
    var coordinates = new google.maps.LatLng(loc[1], loc[2]);
    bounds.extend(coordinates);
    var marker = new RichMarker({
      position: coordinates,
      map: map,
      zIndex: coordinates[3],
      content: '<div class="myClass">TEXT</div>'
    });
    var shadow = marker.getShadow();
    marker.setShadow("");
  }
  map.fitBounds(bounds);


}
google.maps.event.addDomListener(window, "load", initialize);
html,
body,
#map_canvas {
  height: 100%;
  width: 100%;
  margin: 0px;
  padding: 0px
}
<script src="https://maps.googleapis.com/maps/api/js"></script>
<script src="https://google-maps-utility-library-v3.googlecode.com/svn/trunk/richmarker/src/richmarker.js"></script>
<div id="map_canvas" style="border: 2px solid #3872ac;"></div>