openlayers 3 try to load geojson object - openlayers-3

Im a bit new to workng with openlayers 3.
im trying to load a geojson object in openlayers 3 but it display the center only point[0,0], which not even in my geojson object, where im i going wrong.
the code is below:
//CREATE A BASE LAYER
var raster = new ol.layer.Tile({
source: new ol.source.OSM()
});
// create a source from the feature
var source = new ol.source.GeoJSON(
({
object:
{
'type': 'FeatureCollection',
'crs': {
'type': 'name',
'properties': {'name': 'EPSG:3857'}
},
'features': [
{
'type': 'Feature',
//'properties': {'id': 63},
'geometry': {
'type': 'Point',
'coordinates': [12, 12]
}
},
{
'type': 'Feature',
'properties': {'id': 62},
'geometry': {
'type': 'Point',
'coordinates': [35.0, 1.0]}
},
{
'type': 'Feature',
'properties': {'id': 61},
'geometry': {
'type': 'Point',
'coordinates': [34.0, 0.0]}
},
{
'type': 'Feature',
'properties': {
'id': 56
},
'geometry': {
'type': 'Point',
'coordinates': [33.0, 33.0]
}
}
]
}
})
);
// CREATE THE LAYER WITH THE DATA
var vectorLayer = new ol.layer.Vector({
source: source
});
// create an openlayers map object
var map = new ol.Map({
target: attrs.id,
layers: [raster,vectorLayer],
view: new ol.View({
//projection:'EPSG:4326',
center:[0,0],
zoom:2
})
});
}

i figured it out, i had to do a reprojection of my geojson object,
openlayers3 by default uses epsg:3857,so does my base map which is openstreetmap i.e projected coordinate system, so i had to turn my geojson to a projected system since it was coming in using the longitude and latitudes i.e. geographical coordinate system.(geojson is always espg:4326)
var source = new ol.source.GeoJSON({
object:{
'type': 'FeatureCollection',
'crs': {
'type': 'name',
'properties': {'name': 'EPSG:4326'}
},
'features': [
{
'type': 'Feature',
//'properties': {'id': 63},
'geometry': {
'type': 'Point',
'coordinates': [12, 12]
}
},
{
'type': 'Feature',
'properties': {'id': 62},
'geometry': {
'type': 'Point',
'coordinates': [35.0, 1.0]}
},
{
'type': 'Feature',
'properties': {'id': 61},
'geometry': {
'type': 'Point',
'coordinates': [34.0, 0.0]}
},
{
'type': 'Feature',
'properties': {
'id': 56
},
'geometry': {
'type': 'Point',
'coordinates': [33.0, 33.0]
}
}
]
},
projection: 'EPSG:3857'
}
);

Related

Click on images in adaptive card is not triggering action on IOS devices

Click on images in the adaptive card is not triggering action on IOS devices despite its opening the image viewer.
click is working expected on the web app, desktop app, and Android devices
but failing on ios devices.
adaptive card with the clickable image.
after clicking its opening like this.
Card Json:
{
'contentType': 'application/vnd.microsoft.card.adaptive',
'content': {
'type': 'AdaptiveCard',
'version': '1.2',
'body': [
{
'type': 'TextBlock',
'size': 'medium',
'weight': 'Bolder',
'text': 'Here is the list of top analysis created for you: '
},
{
'type': 'ColumnSet',
'columns': [
{
'type': 'Column',
'spacing': 'medium',
'items': [
{
'type': 'Container',
'items': [
{
'type': 'Image',
'url': {image_url},
'horizontalAlignment': 'Center',
'width': '96px',
'height': '96px'
}
],
'selectAction': {
'type': 'Action.Submit',
'tooltip': 'Submit action',
'data': {
'bot_id': 113
}
}
},
{
'type': 'ColumnSet',
'verticalAlignment': 'Center',
'columns': [
{
'type': 'Column',
'items': [
{
'type': 'TextBlock',
'text': 'Beagle Recruit',
'horizontalAlignment': 'Center',
'weight': 'bolder',
'wrap': True,
'maxLines': 2
}
]
}
]
}
],
'width': 'stretch',
'horizontalAlignment': 'Center'
}
],
'horizontalAlignment': 'Center'
},
{
'type': 'ColumnSet',
'columns': [
],
'horizontalAlignment': 'Center'
},
{
'type': 'TextBlock',
'text': 'Select more analysis from the drop-down: ',
'spacing': 'extralarge',
'weight': 'Bolder',
'wrap': True
},
{
'type': 'Input.ChoiceSet',
'id': 'botid_d',
'spacing': 'large',
'isMultiSelect': False,
'value': 0,
'placeholder': 'List of analysis',
'choices': [
{
'title': 'List of analysis',
'value': 0
},
{
'title': 'Beagle Recruit',
'value': 113
}
]
},
{
'type': 'ActionSet',
'style': 'default',
'spacing': 'large',
'actions': [
{
'type': 'Action.Submit',
'color': 'default',
'title': 'Open'
}
]
}
],
'msteams': {
'width': 'Full'
}
}
}
We tried with the below json and it worked for us both in teams desktop/web and mobile clients(iOS). On click of images is triggering action. Could you please refer this?
JSON:
{
"type": "AdaptiveCard",
"body": [
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"width": "auto",
"items": [
{
"type": "Image",
"url": "https://demo-res.cloudinary.com/image/upload/sample.png",
"altText": "Navigation and Help",
"selectAction": {
"type": "Action.Submit",
"title": "Navigation and help",
"data": {
"msteams": {
"type": "imBack",
"value": "Can you help me with Navigation and Help"
}
}
},
"horizontalAlignment": "Center",
"width": "100px"
}
],
"height": "stretch",
"horizontalAlignment": "Center",
"spacing": "Padding"
},
{
"type": "Column",
"width": "auto",
"items": [
{
"type": "Image",
"url": "https://demo-res.cloudinary.com/image/upload/sample.png",
"altText": " Learning and development",
"selectAction": {
"type": "Action.Submit",
"title": "Learning and development",
"data": {
"msteams": {
"type": "imBack",
"value": "Can you help me with Learning and development"
}
}
},
"horizontalAlignment": "Center",
"width": "100px"
}
],
"horizontalAlignment": "Center",
"spacing": "Padding"
}
],
"style": "default",
"horizontalAlignment": "Center",
"spacing": "Padding",
"height": "stretch"
},
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.1"
}

Getting Unsuccessful webhook call: Failed to translate JSON to ExecuteHttpResponse for table in #assistant/conversation

I am trying to show a table in my cloud function using the new #assistant/conversation with the array of data but when i test the action i am getting the error as below
Unsuccessful webhook call: Failed to translate JSON to ExecuteHttpResponse
But when i check the logs i am getting the row values like below
{
"responseJson": {
"session": {
"id": "ABwppHE5M8EGlWf3YmpUUGPQ5xxHh-cb2QYyF_YUarZbF_jXq-Ad2iKDtyI8XAyvWPp4hHnQockBWMZuQA",
"params": {},
"languageCode": ""
},
"prompt": {
"override": false,
"content": {
"table": {
"button": {},
"columns": [
"Date",
"Time",
"Place"
],
"image": {},
"rows": [
"20-10-2020",
"11:20",
"Test"
],
"subtitle": "",
"title": ""
}
}
}
}
}
Here is the implementation of my adding table in the conv
const tempDatas = ['20-10-2020', '11:20', 'Test'];
conv.add(
new Table({
dividers: true,
columns: ['Date', 'Time', 'Place'],
rows: tempDatas
})
);
I have used the same logic in google-actions plugin there it works fine.I have imported the Table like below
const { conversation, Table } = require('#assistant/conversation');
Fixed the issue. The structure provided by the new actions builder is little different with the old one
New Structure:
conv.add(new Table({
'title': 'Table Title',
'subtitle': 'Table Subtitle',
'image': ASSISTANT_LOGO_IMAGE,
'columns': [{
'header': 'Column A',
}, {
'header': 'Column B',
}, {
'header': 'Column C',
}],
'rows': [{
'cells': [{
'text': 'A1',
}, {
'text': 'B1',
}, {
'text': 'C1',
}],
}, {
'cells': [{
'text': 'A2',
}, {
'text': 'B2',
}, {
'text': 'C2',
}],
}, {
'cells': [{
'text': 'A3',
}, {
'text': 'B3',
}, {
'text': 'C3',
}],
}],
}));
You can simplify it like below that is the solution for my above issue
const tableRows = [];
tablesRows.push({ 'cells': [{ 'text': moment(data.date).format('DD-MM-YYYY') }, { 'text': data.time }, { 'text': data.place }] });
conv.add(new Table({
'columns': [{
'header': 'Date',
}, {
'header': 'Time',
}, {
'header': 'Place',
}],
'rows': tablesRows,
}));
For more info visit conversation components

HIghchart Treemap - Add double click event on legend click

Pls find the link for treemap http://jsfiddle.net/BlackLabel/m0587v4q/.
What I need is when I double click on legend it should show that respective data only on tree map and rest should hide.
$('#container').highcharts({
'chart': {
type: 'treemap'
},
series: [{
data: [{
'name': 'Americas',
'value': 52976,
'color': 'rgba(47,126,216,1)'
}, {
'name': 'Australia',
'value': 41219,
'color': 'rgba(13,35,58,1)'
}, {
'name': 'Europe',
'value': 62756,
'color': 'rgba(139,188,33,1)'
}, {
'name': 'Asia',
'value': 14577,
'color': 'rgba(145,0,0,1)'
}],
legendType: 'point',
showInLegend: true
}]
});
You can use Custom-Events plugin and add double click event in this way:
legend: {
itemEvents: {
dblclick: function() {
console.log('dblclick')
},
click: function() {
console.log('click')
}
}
}
Live demo: http://jsfiddle.net/BlackLabel/6m4e8x0y/4952/
Docs: https://www.highcharts.com/plugin-registry/single/15/Custom-Events

put labels on the right of the chart area in HighCharts

In a Highcharts line chart, I need to put the series name on the right of the last point of each one.
Unfortunately, even if I set chart.spacingRight and chart.marginRight, the space on the right is not used.
Is there any solution/workaround?
Jsfiddle
Highcharts.chart('container', {
chart: {
spacingRight: 200
},
plotOptions: {
series: {
label: {
enabled:false
},
pointStart: 2010,
dataLabels: {
enabled:true,
align:'left',
verticalAlign:'middle',
x:10,
formatter: function() {
return this.series.data.indexOf( this.point ) == this.series.data.length - 1 ? this.series.name : '';
}
}
}
},
series: [{
name: 'Installation',
data: [43934, 52503, 57177, 69658, 97031, 119931, 137133, 154175]
}, {
name: 'Manufacturing',
data: [24916, 24064, 29742, 29851, 32490, 30282, 38121, 40434]
}, {
name: 'Sales & Distribution',
data: [11744, 17722, 16005, 19771, 20185, 24377, 32147, 39387]
}, {
name: 'Project Development',
data: [null, null, 7988, 12169, 15112, 22452, 34400, 34227]
}, {
name: 'Other',
data: [12908, 5948, 8105, 11248, 8989, 11816, 18274, 18111]
}],
});
You can do that with dataLabels.crop:false and dataLabels.overflow: 'allow'
dataLabels: {
overflow: 'allow',
crop:false,
...
Api documentation currently broken, so impossible to put the real link
Fiddle

Highcharts redraw not working with alignTicks

I have updated from version 2.1.6 to 4.0.4 and I have problem with refreshing the alignTicks option.
I start with the property at true and then I set it to false via a button.
From true to false the graph is only updated after a windows resize or if I disable/enable one set of data. From false back to true then it work correctly...
Here an example:
chart = new Highcharts.Chart({
'chart': {
'renderTo': 'graph',
'type': 'line',
'zoomType': 'x',
'alignTicks': true
},
'tooltip': {
'formatter': function () {
var d = new Date(this.x);
return 'Time: <b>' + ('0' + d.getUTCHours()).slice( - 2) + ':' + ('0' + d.getUTCMinutes()).slice( - 2) + ':' + ('0' + d.getUTCSeconds()).slice( - 2) + '</b><br/> Value: <b>' + this.y + '</b>';
}
},
'credits': false,
'title': {
'text': 'Date: 04-11-2014 - Location: Locale'
},
'xAxis': {
'type': 'datetime'
},
'yAxis': [
{
'title': {
'text': 'SK_angle',
'style': {
'color': '#4572A7'
}
},
'labels': {
'style': {
'color': '#4572A7'
}
},
'opposite': false,
'allowDecimals': true
},
{
'title': {
'text': 'EL_angle',
'style': {
'color': '#AA4643'
}
},
'labels': {
'style': {
'color': '#AA4643'
}
},
'opposite': true,
'allowDecimals': true
},
{
'title': {
'text': 'Software Status',
'style': {
'color': '#89A54E'
}
},
'labels': {
'style': {
'color': '#89A54E'
}
},
'opposite': false,
'allowDecimals': false
}
],
'series': [
{
'color': '#4572A7',
'name': 'SK_angle',
'yAxis': 0,
'data': [
[1415064918000,305.89],
[1415064919000,335.0],
[1415064923000,306.05],
]
},
{
'color': '#AA4643',
'name': 'EL_angle',
'yAxis': 1,
'data': [
[1415064918000,37.87],
[1415064919000,37.2],
[1415064923000,37.9],
]
},
{
'color': '#89A54E',
'name': 'Software Status',
'yAxis': 2,
'data': [
[1415064918000,1362],
[1415064919000,1362],
[1415064923000,1256],
]
}
]
});
$('#scaleAlign').click(function() {
if (chart.options.chart.alignTicks) {
chart.options.chart.alignTicks = false;
$('#scaleAlign').attr('value','Align Scale');
}
else {
chart.options.chart.alignTicks = true;
$('#scaleAlign').attr('value','Unalign Scale');
}
chart.isDirtyBox = true;
chart.redraw();
});
http://jsfiddle.net/04Lffe0r/3/
Update the code like this: http://jsfiddle.net/04Lffe0r/4/
By adding this:
chart.series[0].isDirty = true;
Because the series should be set as dirty for the chart to redraw.

Resources