Multi-level Maps

ID #1043

04. How to open some URL when a user clicks on the map?

Note that on a multi-level map you can assign a URL only to objects that do not have deeper map levels associated with them. For example, on the USA multi-level map you can assign a URL to counties and cities, but not to states.

Here is how you can assign a URL to a click on the Lauderdale County in Alabama.

1. Find the map.xml file in the data folder.

2. Open it in any text editor like Notepad and look for a desired name:

...
<name>Alabama</name>
<URL map="us_al.swf" xmlfile1="us_al.xml" xmlfile2="us_al_data.xml">#</URL>
...

Below the name tag you should see the filename of the XML that contains the map layer for that particular region. In our case it is us_al.xml – the XML containing the layer with Alabama counties.

3. Open that file in a text editor and look for lines:

...
<name>Lauderdale</name>
<URL>http://www.mysite.com</URL> 
...

Write the URL you need within this tag as shown above.

Any valid URL will suite here. Additionally, you can specify custom JavaScript code here:

...
<URL>javascript:window.alert(‘Hello world!’)</URL>
...

If you want to execute some JavaScript and open the next map layer when a user clicks on the map, please contact us and we will modify the map accordingly for you.

In order to assign a certain URL to a city (or another region on a deeper layer of the map), you should do the following:

4. Find the file of the next layer. Its name is similar to the name of XML but with the “data” suffix, in our case it is us_al_data.xml. You may have noticed that name in the code above in the xmlfile2 parameter:

...
<name>Alabama</name>
<URL map="us_al.swf" xmlfile1="us_al.xml" xmlfile2="us_al_data.xml">#</URL>
...

 5. Open the file in a text editor and find the city you need, then insert the URL in the link property:

...
<p name="Birmingham" link="http://www.fla-shop.com" type="font1" x="-7" y="-72" x_h="-2.8" y_h="-6.1" info="" frame="" img="" symbol="arrow1" />
...

Now, when you click on the city, it will open the specified link.

There is a more convenient way, however. You can use the built-in WYSIWYG editor to generate XML automatically. Open the preview of the map using the index.html file in your purchased zip file. In the preview, scroll down until you see the WYSIWYG map editor. It allows you to add, edit and remove pinpoints and to copy the corresponding XML to the clipboard. All you need then is to paste that XML code to an appropriate file – either map_data.xml or the XML of a particular layer (for instance, us_al_data.xml as shown above).

Tags: -

Related entries:

Last update: 2011-05-11 19:53
Author: Fla-shop Team
Revision: 1.4

Digg it! Share on Facebook Print this record Send FAQ to a friend Show this as PDF file
Please rate this FAQ:

Average rating: 0 (0 Votes)

completely useless 1 2 3 4 5 most valuable

You cannot comment on this entry