Zh OpenStreetMap Visualization: Difference between revisions
mNo edit summary |
mNo edit summary |
||
Line 136: | Line 136: | ||
[[File:Visualization-DataSQL-Main-2.png]] | [[File:Visualization-DataSQL-Main-2.png]] | ||
Here I use joomla notation for table | Here I use joomla notation for table. | ||
The result screens will be the same (because the same data). | The result screens will be the same (because the same data). | ||
=== One column for coordinates (latitude and longitude) === | |||
I will use my table for path data as data source | |||
Here my data for example | |||
[[File:Visualization-Data-3.png]] | |||
Create Structure | |||
[[File:Visualization-Structure-Main-3.png]] | |||
In this case I defined column '''Array of Coordinates'''. It means my column contain array of both coordinates. | |||
As in previous example you have to define '''Separator in coordinates''' because it is coordinates delimiter and '''Coordinates order''', ie how it is stored in your column. | |||
In addition to this you have to define '''Separator in Array''', because it is pair of coordinates delimiter. | |||
It is like as it is done in Path details (''Path'' property), in this property I use comma as delimiter between latitude and longitude, and I use semicolon to separate pairs in array. | |||
[[File:Visualization-Structure-Columns-3.png]] | |||
And my Data Source | |||
[[File:Visualization-DataSQL-Main-3.png]] | |||
Here I use joomla notation for table too. | |||
The result screens will be the same as I will display path by its definition. | |||
== Conclusion == | == Conclusion == |
Revision as of 12:46, 13 November 2019
Preface
Use visualization to show data from other data sources (database tables).
To do it you should do next steps:
- create Structure
- create Data Source, assign your Structure
- create Path or Placemark, assign your Data Source
Here you can see main page for visualization.
Structure
In Structure you enter information about your data, ie column names to use from data source, and other attributes.
Data Source
In Data Source you define SQL statement to get data from database.
For flexible use there is only one field for SELECT statement, you can just create it in phpMyAdmin, copy/paste and use it.
You can use for table names as full names, as names in joomla notation (ie starting from #__)
Examples
Lets create a few examples to show how you can use visualization on your site.
I don't create new tables, I will use tables from my extension.
In Example 1 and Example 2 I set Result Object to Create one object for all rows. It means all my data will be displayed as one object. And result object is Line as I set in Path properties.
Separate columns for latitude and longitude
Here my data for example
Lets create Structure
Add main information
Add columns description
In this example I created structure, which describe that my data will contain two columns - lat and lng.
For this our test example we have to define only two fields.
In other words my SQL will have columns lat and lng
When come back to Structure list we can see our Structure.
For easy way you can press Close button in toolbar to return to main visualization page
Now we need to create Data Source.
As you can see I use table for placemarks, because it contains latitude and longitude in different fields.
I added aliases for my columns, because I describe in Structure names which differ from table column names.
And as you can see in this source I use our Structure.
When come back to Data Source list we can see our Data Source
Now lets show this data.
Go to Paths and create new one
Here you set Object Type and Visualization Data Source.
And on details page we need define some attributes to our Line
As you can see I set Hover Color.
Moreover I enter Addition HTML text, set Action by click to open popup and other Path properties.
Publish Path and lets check
Main view
Hover
Click
One column for coordinates (latitude and longitude)
I will rewrite my SQL to get one column, I just concatenate columns
Here my data for example
Create Structure
In this case I defined column Coordinates. It means my column contain both coordinates.
Moreover you have to define Separator in coordinates because it is coordinates delimiter.
In addition to this you have to define Coordinates order, ie how it is stored in your column.
And my Data Source
Here I use joomla notation for table.
The result screens will be the same (because the same data).
One column for coordinates (latitude and longitude)
I will use my table for path data as data source
Here my data for example
Create Structure
In this case I defined column Array of Coordinates. It means my column contain array of both coordinates.
As in previous example you have to define Separator in coordinates because it is coordinates delimiter and Coordinates order, ie how it is stored in your column. In addition to this you have to define Separator in Array, because it is pair of coordinates delimiter.
It is like as it is done in Path details (Path property), in this property I use comma as delimiter between latitude and longitude, and I use semicolon to separate pairs in array.
And my Data Source
Here I use joomla notation for table too.
The result screens will be the same as I will display path by its definition.
Conclusion
As you can see you can easy create visualization, easy control behaviour your map objects.
Structure is separated from Data Source for flexible use, you can create one Structure definition and many Data Sources (with different WHERE clause for main SELECT)