Mapbox gl filters from a geojson external file - geojson

How can I replace in this example the mapbox url with an external geojson file?
https://docs.mapbox.com/mapbox-gl-js/example/filter-features-within-map-view/
//'type': 'vector',
//'url': 'mapbox://mapbox.04w69w5j'
'type': 'geojson',
'url': 'mapbox://mapbox.04w69w5j'
});
and be able to filter it in the same way.

To use an external geojson file, in 'map.addSource' you need to replace 'url' with 'data'.
'type': 'geojson'
'data': 'yourfile.geojson'
Then in 'map.addLayer' remove the line
'source-layer': 'ne_10m_airports',

Related

Google Action Console(Cloud function editor) How to add image to a Media/MediaObject

Hi i'am working with google assistant, i'am using Action Builder in the Google Action Console. And i working with google Cloud function editor provided in the Action Console to test my webhook. I would like to use a media player to read an mp3 song that i provide with an url. i followed the documentation here : https://developers.google.com/assistant/conversational/prompts-media and i used this code :
app.handle('media', (conv) => {
conv.add('This is a media response');
conv.add(new Media({
mediaObjects: [
{
name: 'Media name',
description: 'Media description',
url: 'https://storage.googleapis.com/automotive-media/Jazz_In_Paris.mp3',
image: {
large: JAZZ_IN_PARIS_IMAGE,
}
}
],
mediaType: 'AUDIO',
optionalMediaControls: ['PAUSED', 'STOPPED'],
startOffset: '2.12345s'
}));
});
Problem is that this code work when i remove the image but if i keep it i got an error :
Unsuccessful webhook call due to client issue: Error querying agent endpoint. State: URL_UNREACHABLE, reason: UNREACHABLE_5xx.
and in the webhookResponse i got :
"error": "JAZZ_IN_PARIS_IMAGE is not defined"
My question is how to send image in a MediaObject send by a webhook? Where do i have to store my image and how to add it in the response?
In the code snippet, JAZZ_IN_PARIS_IMAGE is not defined directly but is supposed to be an Image object, like png or jpg. A MediaObject can have a large image and/or an icon.
For testing purposes, you can upload a file to your Cloud Storage or just take any image from the web. But when you move forward you really should fix that image URL and provide corrected alt text.
conv.add('This is a media response');
conv.add(new Media({
mediaObjects: [
{
name: 'Media name',
description: 'Media description',
url: 'https://storage.googleapis.com/automotive-media/Jazz_In_Paris.mp3',
image: {
large: {
url: 'https://serebii.net/pokearth/sprites/green/025.png',
alt: 'This is a sprite of Pikachu!',
},
}
}
],
mediaType: 'AUDIO',
optionalMediaControls: ['PAUSED', 'STOPPED'],
startOffset: '2.12345s'
}));
});

File Upload is not uploading in React Native iOS, Same is working in android platform

I am try to upload the document, file from react native app. The api is working fine in Android platform but in iOS, I am not able to upload the same. I am using apisauce version ^2.0.0, the strange thing I am not getting any error. Server did not get the request.
Following is the form data:
{ "_parts": [ [ "attachment", { "uri": "file:///Users/yogeshchauhan/Library/Developer/CoreSimulator/Devices/3BCF94FF-0E3E-41E4-B1D5-700E1F85BF4F/data/Containers/Data/Application/9E8CB982-DB6F-439F-BFB8-0DB341E15768/Library/Caches/ImageManipulator/0D8DAD55-4658-4132-A118-12F2302ACF93.jpg", "type": "image/jpeg", "name": "C23BD088-411F-4C4A-A6B0-82DB9945D49A.jpg" } ] ] }
I am using the following version of react:
"react": "16.13.1",
"react-native": "0.63.0"
In iOS you have to remove file:// from the uri, pass image path without file://. For example on file select set selected image in one of your state variable for example call it selectedImage. And when you pass on image replace file:// with blank string based on device like this :
const datas = new FormData();
datas.append('images', {
name: selectedImage.fileName,
type: selectedImage.type,
uri:
Platform.OS === 'android' ? selectedImage.uri : selectedImage.uri.replace('file://', ''),
});

Get Highchart (/ Highstock) from public data (json)

Here's an example how to plot the chart with json data
Is there a way to chart this from public data (meaning any listed company)? For example from bloomberg data? https://www.bloomberg.com/markets/chart/data/1D/AAPL:US
I guess the format is just wrong?
For Highcharts the structure of data is important, not the source. All you should do is set the correct link and series data, but unfortunately I see a problem with CORS: How does Access-Control-Allow-Origin header work?
series: [{
data: data.data_values,
...
}]
Live demo: http://jsfiddle.net/BlackLabel/5u0jv31y/

HighCharts Editor Plugin Example not working

So I have the jquery-simple-rest plugin for Highcharts, (same used in the example documentation). I've linked the js file, and am not getting any errors in my browser. The documentation mentions also needing to the highed.use.
//The installer
highed.plugins.editor.install("jquery-simple-rest",{
//Contains information about the plugin - optional
meta:{
version:"1.0.0",
author:"Highsoft",
homepage:"https://github.com/highcharts/highcharts-editor/plugins/jquery-simple-rest.js"
},
//Add additional external dependencies here
dependencies:[
"https://code.jquery.com/jquery-3.1.0.min.js"
],
//This is the prototype options which the plugin accepts
options:{
url:{
required:!0,
type:"string"}
},
//Called when the chart changes
chartchange:function(e,t)
{jQuery.ajax({
url:t.url,
data:e.json,
dataType:"json",
type:"post"
,success:function(){
highed.snackBar("CHART SAVED")
},
error:function(e,t){
highed.snackBar("unable to save chart: "+t)
}
})
}
});
highed.plugins.editor.use('jquery-simple-rest', {options:{
url:{
required:!0,
type:"string"}
},
}
);
I can not get this plugin to appear in my the editor, and have no idea what it is I'm doing wrong.
link to example: https://github.com/highcharts/highcharts-editor/wiki/Plugins

Using a geojson with highmaps

I want to display some data about San Francisco using highmaps but there is no maps of the different neighborhoods in SF in the highmaps library so I found an geojson of San Francisco wich was validate by this site: geojson validator but when I use the highmaps validator he doesn't read it: the highmap validator
$('#run').click(function () {
var geojson = $.parseJSON($('#geojson').val());
// Initiate the chart
$('#container').slideDown().highcharts('Map', {
series: [{
mapData: geojson
}]
});
});
This is my geojson: pastebin code.
Do you know why it's not validated by highmaps but it's validate by the geojson validator? Or do you know a San Francisco map which will be validated by highmaps?
Consider importing your .geojson into QGis, then exporting it out again. In my experience any .geojson that QGis produces is usable by Highmaps. Also see this tutorial Creating custom geojson maps for Highmaps with QGis.

Resources