0

こんにちは、マップ内のマーカーを変更します。Rails を使用し、マーカーを設定するためのこの JavaScript 関数を作成したので、マーカーを URL: "icona.png" で変更すると、icona.png はリソース プロモーションの同じフォルダーにあります。いいえ、地図上のマーカーを表示しません。なんで?別の方法があるデフォルトの市場をどのように変更しますか?

      function setMarkers(map, locations) {
      // Add markers to the map

      // Marker sizes are expressed as a Size of X,Y
      // where the origin of the image (0,0) is located
      // in the top left of the image.

      // Origins, anchor positions and coordinates of the marker
      // increase in the X direction to the right and in
      // the Y direction down.
      var image = {
          url: "icona.png",
          // This marker is 20 pixels wide by 32 pixels tall.
          size: new google.maps.Size(20, 32),
          // The origin for this image is 0,0.
          origin: new google.maps.Point(0,0),
          // The anchor for this image is the base of the flagpole at 0,32.
          anchor: new google.maps.Point(0, 32)
      };
      var shadow = {
          url: "icona.png",
          // The shadow image is larger in the horizontal dimension
          // while the position and offset are the same as for the main image.
          size: new google.maps.Size(37, 32),
          origin: new google.maps.Point(0,0),
          anchor: new google.maps.Point(0, 32)
      };
      // Shapes define the clickable region of the icon.
      // The type defines an HTML <area> element 'poly' which
      // traces out a polygon as a series of X,Y points. The final
      // coordinate closes the poly by connecting to the first
      // coordinate.
      var shape = {
          coord: [1, 1, 1, 20, 18, 20, 18 , 1],
          type: 'poly'
      };
4

1 に答える 1

3

javascript をapp/assets/javascripts/に、マーカーをapp/assets/images/フォルダーに配置してみてください。次に、画像にルーティングします: "/assets/marker.png"

詳細はhttp://guides.rubyonrails.org/asset_pipeline.htmlで読むことができます

于 2013-05-31T23:07:28.963 に答える