0

我有一个新问题。

我已经完成了我的小部件,但现在我想要数据库中 5 个类别的 5 个评级小部件。

我的数据库中有这个列(名为places.categ):

places.categ
       a
       b
       c
       d
       a
       e
       ....

我的谷歌地图中有 21 个标记,每个标记都属于一个类别。(a、b、c、d 或 e)。

如何按类别将 5 个评分小部件与这 21 个标记相关联?我所能做的就是:

db.define_table('product',
Field('A', 'integer',requires=IS_IN_SET(range(1,6))), 
   Field('B', 'integer',requires=IS_IN_SET(range(1,6))),
   Field('C', 'integer',requires=IS_IN_SET(range(1,6))),
   Field('D', 'integer',requires=IS_IN_SET(range(1,6))),
   Field('E', 'integer',requires=IS_IN_SET(range(1,6))))

我的模型/db.py 中有这个代码,我的控制器/default.py 中有这个代码:

from plugin_rating_widget import RatingWidget

# Inject the widgets
db.product.A.widget = RatingWidget()
db.product.B.widget = RatingWidget()
db.product.C.widget = RatingWidget()
db.product.D.widget = RatingWidget()
db.product.E.widget = RatingWidget()




# form2 = SQLFORM.factory(
   # Field('Rating','integer',widget=SQLFORM.widgets.RatingWidget))

   # if form2.process().accepted:
   #     print form2.vars.search



form2 = SQLFORM(db.product)
if form2.accepts(request.vars, session):
    session.flash = 'submitted %s' % form2.vars
    redirect(URL('index'))

我有 5 个评级小部件,但它们与我的数据库无关,它们是垂直的(5 行)而不是 1 行,就像我想要的那样。

TIA。

PS:我已经上传了插件评级小部件。

4

1 回答 1

0

I solved in another way. I get colors to each category with this code:

var amarelo = new google.maps.MarkerImage(
  "http://labs.google.com/ridefinder/images/mm_20_yellow.png",
  new google.maps.Size(12, 20),
  new google.maps.Point(0, 0),
  new google.maps.Point(6, 20));
var vermelho = new google.maps.MarkerImage(
  "http://labs.google.com/ridefinder/images/mm_20_red.png",
  new google.maps.Size(12, 20),
  new google.maps.Point(0, 0),
  new google.maps.Point(6, 20));
var verde = new google.maps.MarkerImage(
  "http://labs.google.com/ridefinder/images/mm_20_green.png",
  new google.maps.Size(12, 20),
  new google.maps.Point(0, 0),
  new google.maps.Point(6, 20));
var azul = new google.maps.MarkerImage(
  "http://labs.google.com/ridefinder/images/mm_20_blue.png",
  new google.maps.Size(12, 20),
  new google.maps.Point(0, 0),
  new google.maps.Point(6, 20));
var branco = new google.maps.MarkerImage(
  "http://labs.google.com/ridefinder/images/mm_20_white.png",
  new google.maps.Size(12, 20),
  new google.maps.Point(0, 0),
  new google.maps.Point(6, 20));
var sombra = new google.maps.MarkerImage(
  "http://labs.google.com/ridefinder/images/mm_20_shadow.png",
  new google.maps.Size(22, 20),
  new google.maps.Point(0, 0),
  new google.maps.Point(6, 20));

I awarded each category in one of this colors (example):

if (placescoordjs[i][4]== 'a')
    {
    marker = new google.maps.Marker({
        position: new google.maps.LatLng(placescoordjs[i][1],placescoordjs[i][2]),
        icon: amarelo, shadow: sombra,
        map: map,
        title: placescoordjs[i][3]
    });
    google.maps.event.addListener(marker, 'click', (function(marker, i) {
        return function() {
            infowindow.setContent(placescoordjs[i][0]);
            infowindow.open(map, marker);
        }
    })(marker, i));
     }

I have more 3 "else if" and the final else with the final color to my last category.

Thanks anyway. ;)

于 2013-06-24T16:48:12.860 回答