adding openweather data to mapbox map - mapbox

So im trying to add weather data to my mapbox map. Im using for the data the openweather api. Im trying to add the data via adding a layer with the weather data tiles. Here's my current code: ` var map1 = "https://tile.openweathermap.org/map/temp_new/{z}/{x}/{y}.png?appid=e7fef929605b6a73c6921e4fec83f6ce"
map.on('load', function(){
map.addLayer({
"id": "simple-tiles",
"type": "raster",
"source": {
"type": "raster",
"tiles": ["https://tile.openweathermap.org/map/temp_new/{z}/{x}/{y}.png?appid=e7fef929605b6a73c6921e4fec83f6ce"],
"tileSize": 256
},
"minzoom": 0,
"maxzoom": 22
});
});`
So if i do it like this it works totaly fine, but if i try to add weather tileset trough a link provided on the openweather website it doesnt work. Also the link is quiet different. For example i want to add this map: http://maps.openweathermap.org/maps/2.0/weather/PA0/{z}/{x}/{y}?date=1527811200&appid={API key} it doesnt work. And yes i changed the api key placeholder with my api key. So any suggestions why its not working with this other link and how to fix that problem. Maybe iam just stupid but thanks in advance.

Related

Mapbox - How to properly use the Tilesets API

I am trying to update my existing tileset with new data. In postman, I sucessfully send the following;
https://api.mapbox.com/tilesets/v1/sources/{{usermame}}/testing?access_token={{admin-access-token}}
In the body, I have added a new line delimited geojson, as required, with the following key/value pair;
key: file
value: file_nd.geojson
As a reply I get the following;
status: ok
{
"id": "mapbox://tileset-source/{{username}}/testing",
"files": 1,
"source_size": 1131168,
"file_size": 1131168
}
When I go to the tileset tab on the mapbox website, the modified time does not change and the data is not updated. I did notice though that if I look at tileset sources in postman using the following;
https://api.mapbox.com/tilesets/v1/sources/{{username}}?access_token={{admin-access-token}}
This is returned;
{
"id": "mapbox://tileset-source/{{username}}/testing",
"size": 1131168,
"files": 1
},
So I am guessing that it has not yet been converted to a tileset. I cannot see in the documentation how to trigger the conversion via the API. Any help appreciated.

how to query custom dimension google anaylitics api

I have setup a custom dimension in google analytics 'dimension2' into which I want to capture a WPForms UniqueID. I added this to Google Tag manager and I can see the custom dimension with a value when I preview site in GTA preview.
. I added this to gtags.js on this word press site,
var dimensionValue = $.cookie("_wpfuuid");
gtag('config', 'UA-1234567890-2', {
'custom_map': {'dimension2': 'wpfid'}
});
gtag('set', 'dimension2', {'wpfid': dimensionValue});
In google analytics query explorer, I can see dimension2 in the test results.
"columnHeaders": [
{
"name": "ga:dimension2",
"columnType": "DIMENSION",
"dataType": "STRING"
},
{
"name": "ga:users",
"columnType": "METRIC",
"dataType": "INTEGER"
}
],
"totalsForAllResults": {
"ga:users": "1"
},
"rows": [
[
"40502794-ecf1-4cf6-97b9-2c16c7f6c949",
"1"
]
]
And, I can see the dimension2 data in google analytics user explorer, so it is making it to the browser interface for analytics.
However, when I add the following to my API query script, it breaks and is not generating any php errors, or the error is that it does not recognize 'dimension2'. I tried this on 2 views and both act the same. Here is my code to add the custom dimension to my query
$dimension = new Google_Service_AnalyticsReporting_Dimension();
$dimension->setName("ga:dimension2");
What am I missing? Why isn't this visible in google api results and/or where I can I see any errors?
Some hours later, this code started to work, which suggests to me that custom dimensions are not immediately available to the api. In this case the api recognized dimension2 long after the data was visible in the analytics website.
Second possibility to check which can cause this seemingly good code to not work, you are using the wrong view id. Of the 2 views I tested, this only works on one.

Mapbox Studio edit of style updated via REST API

We created a dataset, tileset, and style via Mapbox Studio
It was very simple with only one colored layer.
Then we used the REST API to add many layers.
For example, (reference see: https://www.mapbox.com/api-documentation/#update-a-style)
The style.json file has many new layers that were generated via a python script.
"layers": [
...
{"id": "bid_id-WPLNS", "source": "composite", "paint": {"fill-color": "rgba(62,129,54,0.4)"}, "source-layer": "Business_Improvement_Districts", "interactive": true, "filter": ["==", "bid_id", "WPLNS"], "layout": {"visibility": "visible"}, "type": "fill"},
{"id": "bid_id-WSTSH", "source": "composite", "paint": {"fill-color": "rgba(17,31,177,0.4)"}, "source-layer": "Business_Improvement_Districts", "interactive": true, "filter": ["==", "bid_id", "WSTSH"], "layout": {"visibility": "visible"}, "type": "fill"},
{"id": "bid_id-WSTSQ", "source": "composite", "paint": {"fill-color": "rgba(143,124,110,0.4)"}, "source-layer": "Business_Improvement_Districts", "interactive": true, "filter": ["==", "bid_id", "WSTSQ"], "layout": {"visibility": "visible"}, "type": "fill"},
...
then we issue a REST HTTP PATCH to update the style:
curl -X PATCH
"https://api.mapbox.com/styles/v1/ryozzopanodex/cistmnflb002l2woxcfbgyl3m?access_token=WRITE-TOKEN-HERE"
--data #style.json --header "Content-Type:application/json"
For the result:
see https://city.tidalforce.org/bid
Question WHY when I go to Mapbox Studio and edit the style, do I NOT see the REST API created layers?
I only see the original layers that were created in Studio. If I edit and save, it appears that all the REST API created layers would be overwritten.
Please let us know if there is a way to edit the new layers via Mapbox Studio (which we love!)
it is possible that you are using the REST API to update the published version of the style, but you're viewing the draft version of the style when you attempt to edit the style in Mapbox Studio. Try using the 'revert draft to last published' action from the list or style view page:
revert to last published
and then try to edit the style. Mapbox Studio automatically creates drafts for all styles so that users don't accidentally break styles that are used in production. Once you're satisfied with changes to your draft, you can apply the draft changes to the published style with the 'publish' button in the styl editor.

SharePoint 2013 - Associating Site Columns With Content Types Using the REST API

I'm trying to use the REST API to programatically create site columns and content types. Everything works fine until I try to associate my site columns with my content types.
By this point in my code the site columns and content types already exist...
I am sending a POST to the following URL...
http://mydevmachine/sites/claimsreports/_api/web/ContentTypes('0x01003E9D5AD94A5DCD46876B7BFFCEA9B60C')/FieldLinks
Here is the information I am sending in the request body...
{
"__metadata": {
"type": "SP.FieldLink"
},
"Id": "9400d057-ba2c-4ab4-9ce0-671b858fd849",
"Name": "BusinessCategory",
"Hidden": false,
"Required": false
}
Here is the error I get back in response...
{"error":{"code":"-2147467261, System.ArgumentNullException","message":{"lang":"en-US","value":"Value cannot be null.\r\nParameter name: parameters"}}}
I have tried several other options without success. For example, I have tried using "__metadata" : { "type": "SP.FieldLinkCreationInformation"} but everything I try with this __metadata type result in this error...
{"error":{"code":"-1, Microsoft.SharePoint.Client.InvalidClientQueryException","message":{"lang":"en-US","value":"A type named 'SP.FieldLinkCreationInformation' could not be resolved by the model. When a model is available, each type name must resolve to a valid type."}}}
It sounds like SharePoint is telling me that this "type" is invalid. It seems like this should be possible with SharePoint 2013 since the documentation seems to imply that its possible...
documentation
If anyone has any ideas I would be greatful for the suggestions. Thanks!
Based on the documentation, I would try that:
Endpoint (note the /add at the end):
http://mydevmachine/sites/claimsreports/_api/web/ContentTypes('0x01003E9D5AD94A5DCD46876B7BFFCEA9B60C')/FieldLinks/add
Body (wrap your properties in a parameters property):
{"parameters":
{
"__metadata": {"type": "SP.FieldLink"},
"Id": "9400d057-ba2c-4ab4-9ce0-671b858fd849",
"Name": "BusinessCategory",
"Hidden": false,
"Required": false
}
}

How to get total number of tracks in a playlist using soundcloud json API

I am trying to paginate the track list of a set/playlist obtained via soundcloud JSON API. Pagination technique described here works fine if I want to generate tracklist of x number of tracks for next page only. What I am trying to do is to make a numbered pagination with multiple page links. I didn't find any parameter such as "track_count" which returns the total number of tracks for "/user/tracks". So, can anyone give me any insights on making a numbered pagination for a playlist when getting data via soundcloud JSON API? thanks
/users endpoint has "track_count" property in the returned representation of user:
$ curl "http://api.soundcloud.com/users/3207.json?client_id=YOUR_CLIENT_ID"
{
"id": 3207,
"permalink": "jwagener",
"username": "Johannes Wagener",
"uri": "http://api.soundcloud.com/users/3207",
"permalink_url": "http://soundcloud.com/jwagener",
"avatar_url": "http://i1.sndcdn.com/avatars-000001552142-pbw8yd-large.jpg?142a848",
"country": "Germany",
"full_name": "Johannes Wagener",
"city": "Berlin",
"description": "<b>Hacker at SoundCloud</b>\r\n\r\nSome of my recent Hacks:\r\n\r\nsoundiverse.com \r\nbrowse recordings with the FiRe app by artwork\r\n\r\ntopbillin.com \r\nfind people to follow on SoundCloud\r\n\r\nchatter.fm \r\nget your account hooked up with a voicebox\r\n\r\nrecbutton.com \r\nrecord straight to your soundcloud account",
"discogs_name": null,
"myspace_name": null,
"website": "http://johannes.wagener.cc",
"website_title": "johannes.wagener.cc",
"online": true,
"track_count": 12,
"playlist_count": 1,
"followers_count": 417,
"followings_count": 174,
"public_favorites_count": 26
}
This question is already old, but I hope this could help other people.
You could use either of this endpoint:
http://api.soundcloud.com/playlists/{playlist_id}?client_id={client_id}
https://api.soundcloud.com/playlists/{playlist_id}?oauth_token={oauth_token}
The 2nd API is undocumented, the first endpoint suddenly started to return 401 for no reason which is from the SoundCloud API documentation. I still provided the 1st endpoint as it's only not working at work, but behaves correctly at home IP address. I suggest if you'd use the 2nd API to generate and use a non-expiring token.
SoundCloud is not a reliable provider anymore as there's no app support for developers. You just have to figure things out by yourself.
On the JSON response, look for track_count. That'll give you the number of tracks in a playlist.