Zh OpenStreetMap Visualization

From Documentation
Jump to navigation Jump to search

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.

Visualization-MainPage.png

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,Example 2 and Example 3 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

Visualization-Data.png


Lets create Structure

Add main information

Visualization-Structure-Main.png

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

Visualization-Structure-Columns.png


When come back to Structure list we can see our Structure.

Visualization-Structure-List.png

For easy way you can press Close button in toolbar to return to main visualization page


Now we need to create Data Source.

Visualization-DataSQL-Main.png

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

Visualization-DataSQL-List.png


Now lets show this data.

Go to Paths and create new one

Visualization-Example1-Main.png

Here you set Object Type and Visualization Data Source.

And on details page we need define some attributes to our Line

Visualization-Example1-Details.png

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

Visualization-Example1-1.png

Hover

Visualization-Example1-2.png

Click

Visualization-Example1-3.png


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

Visualization-Data-2.png


Create Structure

Visualization-Structure-Main-2.png

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.

Visualization-Structure-Columns-2.png

And my Data Source

Visualization-DataSQL-Main-2.png

Here I use joomla notation for table.

The result screens will be the same (because the same data).


One column for coordinates array

I will use my table for path data as data source

Here my data for example

Visualization-Data-3.png


Create Structure

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.


Visualization-Structure-Columns-3.png

And my Data Source

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.

Server

In some cases you need to connect to external database servers

In this case you should create server configuration

Visualization-Server.png

As for Driver field, for MySQL you can use mysql or mysqli values, for ms sql server use mssql

And assign it to Data Source

Visualization-Data-Server.png


Add Start and End points for Line

If you set path type to Line (to show your data as line) you can show start and end points of your line.

It can be done in Structure part. There is Line tab with two blocks for markers.

If field Marker set to No – marker is not displayed.

If you not enter Title or Description – the values will be taken from path properties.

You can manage what information will be in popup and what action by click on marker – it is paths properties. Also path properties – URL Site and Site Name you can use too.

Addition HTML text (as it done for markers) will be displayed in any case (if it is exist)

If your path belongs to group, properties for override placemark icon can be applied.

Lets add start and end placemarks.

Go to Structure details, open Lines tab

Add information for marker 1

Visualization-Line-Marker1.png

Add some text to Addition HTML text field

Visualization-Line-Marker1-ai.png

Do the same for marker 2

Visualization-Line-Marker2.png

If we check map now we can see placemarks (probably without popups), we need add some action.

Go to your path details, and define what content of popup we want, what action by click and etc.

Visualization-Line-Path.png

After all out manipulations we have result

Visualization-Line-Result.png


Add date of creation

In some cases we need to add date to out popups.

In our data source we have date to show.

Lets do little changes

In Data Source will add createddate, it is column where our date is

Visualization-Date-DataSQL.png

In Structure will add our column name to definition

Visualization-Date-Structure.png

After that we need to enable showing placemarks date of creation in map properties.

Go to your map details, placemarks tab

Visualization-Date-Map.png

Last field Show placemark creation set to Date of creation.

It is common way to show this date, not only for this two placemarks.

Check what we get

Visualization-Date-Result1.png

Date will be displayed only it is defined.

Lets change date format. It can be done by map override.

Go to map overrides and create new one.

Define title, after that we need do settings for placemark, therefore go to Placemark tab

Visualization-Date-Override.png

Enter format (it is datetime format for PHP, just search the net for details), save it.

After that go to your map details again, open Advanced settings tab. Scroll down to find Map override field.

Select your map override.

And now we get

Visualization-Date-Result2.png

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)