1

gmap3 を使用していて、カスタム ピンとピン シャドウをマップに追加しましたが、アイコンとシャドウを揃えるのに問題があります。私のコードは次のとおりです。

marker: {
  options: {
    icon: '/media/pins/pin.png',
    iconSize: [26, 30],
    shadow: '/media/pins/pin_shadow.png',
    shadowSize: [44, 30],
    iconAnchor: [13, 70],
  },

オンラインで例を見つけることができなかったので、問題がオプションと呼ぶもの (例: iconSize) にあるのか、それとも値を提供する方法 (例: [13, 70]) にあるのかわかりません。

4

2 に答える 2

3

Duncan が指摘するように、解決策は MarkerImage クラスを使用することです。そして、それを行う方法は次のとおりです。

marker: {
  options: {
    icon:
      new google.maps.MarkerImage('/media/pins/pin.png',   //icon url
      new google.maps.Size(26, 30),    //sets the icon size
      new google.maps.Point(0, 0),    //sets the origin point of the icon
      new google.maps.Point(13, 30)),    //sets the anchor point for the icon
    shadow:
      new google.maps.MarkerImage('/media/pins/pin_shadow.png',
      new google.maps.Size(44, 30),
      new google.maps.Point(0, 0),
      new google.maps.Point(13, 30)),
  },
于 2011-10-11T20:39:16.017 に答える
1

MarkerOptions has no iconSize, shadowSize or iconAnchor properties. It's hard to say if gmap3 takes the options and plugs it straight into MarkerOptions. If it does, you'd need to create the icon and shadow as MarkerImage objects instead.

于 2011-10-11T12:29:01.197 に答える