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 回答