4
$\begingroup$

This is a follow-up question based on the answer I got from Lukas Lang. The original question is here. How can I alter the code to deploy it on the cloud? Or in case this method is only for desktop: how can I replicate this idea for cloud deploy?

CountrySelector[c_, opts : OptionsPattern[]] := 
 iCountrySelector[#, c, opts] &
CountrySelector[Dynamic@var_, c_, opts : OptionsPattern[]] := 
 iCountrySelector[Dynamic@var, c, opts]
iCountrySelector[Dynamic@var_, c_, opts : OptionsPattern[]] :=
 DynamicModule[
  {
    control = Panel@Row@{
      "Loading country selector...",
      ProgressIndicator[Appearance -> "Percolate"]
     }
   },
  Dynamic@control,
  Initialization :> SessionSubmit[
    control = DynamicModule[
      {active, countries = c},
      GeoGraphics[
       {
        MapIndexed[
         EventHandler[
           Style[
            Annotation[Polygon@#, ""],
            TagBoxOptions -> {
              BaseStyle -> FEPrivate`Which[
                FEPrivate`SameQ[active, #2[[1]]],
                {Lighter@Red, EdgeForm@{Thick, Red}},
                FrontEnd`CurrentValue@"MouseOver",
                EdgeForm@Lighter@Red,
                True,
                {}
                ]
              }
            ],
           {
            "MouseClicked" :> (FEPrivate`Set[active, #2[[1]]]; var = #)
            }
           ] &,
         countries
         ]
        },
       opts,
       GeoBackground -> "CountryBorders",
       ImageSize -> Medium
       ]
      ]
    ]
  ]
Manipulate[
 Dynamic@country,
 {{country, None}, CountrySelector@EntityList@EntityClass["Country", "Europe"]}
 ]

I am looking for any advice or just a point in the right direction.

$\endgroup$
2
  • $\begingroup$ I would start with a step by step check, first of all, does this return a list for you: EntityList@EntityClass["Country", "Europe"]? Moreover, I am afraid that FEPrivate` functionality is not supported in the cloud so you need to use BasetStyle -> Dynamic @ Which[.... instead. There's no 100% guarantee it will work so at the end you may need to have Dynamic wrapped around everything. $\endgroup$
    – Kuba
    Commented Dec 4, 2019 at 8:32
  • $\begingroup$ Yes, EntityList@EntityClass["Country", "Europe"] does return a list for me. The piece of code functions nicely in Mathematica, however, as you mention there are functionalities that don't work in the cloud. Sure, I'll try that out. $\endgroup$
    – Tim B
    Commented Dec 4, 2019 at 9:31

0

Your Answer

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

Browse other questions tagged or ask your own question.