Rails如何改变谷歌地图标记?

时间:2013-05-31 16:19:27

标签: ruby-on-rails google-maps google-maps-markers

你好我会改变地图中的标记,我使用rails并且我为set marker写了这个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'
      };

1 个答案:

答案 0 :(得分:3)

尝试将javascript放入 app / assets / javascripts / app / assets / images / 文件夹中的标记。然后路由到图片:“/ assets / marker.png”

您可以在那里阅读更多http://guides.rubyonrails.org/asset_pipeline.html