Page 1 of 1

Downloading map image

Posted: January 15th, 2023, 12:58 am
by mkboynton
I have these three measures I am using attempting to download a map. The latitude and longitude measures work fine, but the map measure will not download the map. If I use the api url with a browser, it renders with no problem. What am I doing wrong?

Code: Select all

[MeasureLatitude]
Measure=WebParser
URL=#Location#
RegExp="(?siU)"latitude":(.*),"longitude":(.*),.*"
;RegExp=(?siU)"loc": "(.*),(.*)"
UpdateRate=3600
Substitute=#Substitute#
StringIndex=1
FinishAction=[!WriteKeyValue Variables Lat [MeasureLatitude] "#SKINSPATH#Droptop Community Apps\Apps\VPN_Status-Mike_Boynton\Variables\Variables.inc"][!WriteKeyValue Variables Long [MeasureLongitude] "#SKINSPATH#Droptop Community Apps\Apps\VPN_Status-Mike_Boynton\Variables\Variables.inc"]

[MeasureLongitude]
Measure=WebParser
URL=[MeasureLatitude]
UpdateRate=3600
Substitute=#Substitute#
StringIndex=2

[MeasureMap]
Measure=WebParser
URL=https://api.mapbox.com/styles/v1/mapbox/streets-v12/static/#Lat#,#Long#,9,0/234x96?access_token=#api_key#
Download=1
DownloadFile=map.png
DynamicVariables=1


Re: Downloading map image

Posted: January 15th, 2023, 11:47 am
by xenium
mkboynton wrote: January 15th, 2023, 12:58 am I have these three measures I am using attempting to download a map. The latitude and longitude measures work fine, but the map measure will not download the map. If I use the api url with a browser, it renders with no problem. What am I doing wrong?

Code: Select all

[MeasureLatitude]
Measure=WebParser
URL=#Location#
RegExp="(?siU)"latitude":(.*),"longitude":(.*),.*"
;RegExp=(?siU)"loc": "(.*),(.*)"
UpdateRate=3600
Substitute=#Substitute#
StringIndex=1
FinishAction=[!WriteKeyValue Variables Lat [MeasureLatitude] "#SKINSPATH#Droptop Community Apps\Apps\VPN_Status-Mike_Boynton\Variables\Variables.inc"][!WriteKeyValue Variables Long [MeasureLongitude] "#SKINSPATH#Droptop Community Apps\Apps\VPN_Status-Mike_Boynton\Variables\Variables.inc"]

[MeasureLongitude]
Measure=WebParser
URL=[MeasureLatitude]
UpdateRate=3600
Substitute=#Substitute#
StringIndex=2

[MeasureMap]
Measure=WebParser
URL=https://api.mapbox.com/styles/v1/mapbox/streets-v12/static/#Lat#,#Long#,9,0/234x96?access_token=#api_key#
Download=1
DownloadFile=map.png
DynamicVariables=1

Add in the Rainmeter section DynamicWindowSize=1

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
I do not see in the code posted by you but I assume that code also contains a meter like this:

Code: Select all

[MeterMap]
Meter=IMAGE
MeasureName=MeasureMap
Otherwise you will not see any map.

Re: Downloading map image

Posted: January 15th, 2023, 2:51 pm
by balala
mkboynton wrote: January 15th, 2023, 12:58 am I have these three measures I am using attempting to download a map. The latitude and longitude measures work fine, but the map measure will not download the map. If I use the api url with a browser, it renders with no problem. What am I doing wrong?
xenium's reply might be important, but probably it's not enough at all, because looking to the code, I see that the Lat and Long variables are set by the FinishAction option of [MeasureLatitude] measure, by writing them as two variables, into a file (in this case to Skins\Droptop Community Apps\Apps\VPN_Status-Mike_Boynton\Variables\Variables.inc). Writing them this way doesn't let the [MeasureMap] measure to use them, because to get the measure working with the written variables, the skin has to be refreshed. Instead of this, a dynamic setting of the variables would be much better, using !SetVariable bangs and if do this, the [MeasureMap] measure will be able to use them, but it has to be updated, in order to get the image downloaded.
First of all, a thing which I say more and more often: you should help us to can help you. So don't post only some piece of your code (three measures this time), but the whole code, including the needed variables. Most important is the Location variable, in order to can check what the [Measure Latitude] and [MeasureLongitude] measures are returning and to can give a proper solution, which is definitely not impossible (at least I hope), but needs to be chaecked.