It is currently March 28th, 2024, 4:07 pm

Downloading map image

Get help with creating, editing & fixing problems with skins
Post Reply
mkboynton
Posts: 23
Joined: January 31st, 2016, 10:52 pm

Downloading map image

Post 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

User avatar
xenium
Posts: 841
Joined: January 4th, 2018, 9:52 pm

Re: Downloading map image

Post 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.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Downloading map image

Post 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.
Post Reply