0
$\begingroup$

In my previous question here, I had a problem with showing GeoGraphics in a CDF document, but thanks to other users, I was able to solve it. But the code I wrote to test my work gave an error. I tried the code again and I got the same error.

Manipulate::vstype: ControlType -> PopupMenu is not supported for the variable specification {route$$,names}. ControlType -> InputField will be used instead

I tried to initialize the route variable in the Initialization option, but my code still does not work. Any Ideas?

Manipulate[
 If[route == "All",
    ruta = "all routes",
    p = Position[names, route][[1, 1]];
    If[NumberQ[p] == True,
       ruta = p - 1,
       ruta = p
    ]
 ];

 Row[{names, "\n", rp[[All, 1]], "\n", routesPosition[[1]], "\n", 
   route, "\n", ruta}],

 Control @ {route, names},
 TrackedSymbols :> {route, names, point},

 Initialization :> (
    routesPosition = 
    Import["http://sitiopruebamathematica.altervista.org/rutas.xml", 
     "XML"];
    rp = Cases[routesPosition, XMLElement["ROW", _, _], Infinity] /. 
      XMLElement[_, _, {val_}] :> val /. 
     XMLElement["ROW", _, list_] :> list;
    names = Insert[rp[[All, 1]], "All", 1];
    point = ToExpression[rp[[All, 2]]];
    ruta = "all routes";
    route = names[[1]];
   ),
 SynchronousInitialization -> False,
 SaveDefinitions -> True,
 ControlType -> PopupMenu
 ]
$\endgroup$

1 Answer 1

2
$\begingroup$

I can't run your code, so I can't offer you a working modification to your code, but only offer advice.

Popup menus can't be specified in the way you have tried to do it. Here is an example of a demonstration with a popup menu specified in the conventional way (which is simple). I hope you can adapt it to your needs.

With[{maxK = 3},
  With[{lbls = TraditionalForm /@ Table[Sin[k "t" + "ϕ"], {k, maxK}]},
    With[{rules = Thread[Rule[Range @ maxK, lbls]]}, 
      Manipulate[
        Plot[Sin[k t + ϕ], {t, 0, 2 π}], 
        {{k, 2, "function"}, rules, PopupMenu},
        {ϕ, 0., 1. π, π/8., Appearance -> "Labeled"}]]]]

demo

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.