weblinksmap – Google maps in Postnuke

  • Beitrags-Autor:
  • Beitrags-Kategorie:Computer

So your web site talks a lot about travelling and has photos about all sorts of places? And you would like to link to all those resources on a map like this. Well, if you happen to use PostNuke for your site we got the right hack for you.

After upgrading PostNuke recently and playing with the Google Maps API in a hard coded HTML for a bit I decided that maintaining the HTML file is just too painful. After all we are using PostNuke as a content management system on the site. And the HTML was not even within the site itself. So I migrated the HTML to a PHP file based on blank.php. Since that was still to painful I decided to hack a file together that takes links from the PostNuke web links core module and uses those on the map. And after a bit of hacking I am proud to release weblinksmap.php to you.

Download the release from here and read the weblinksmap_readme.txt for more instructions. An updated and maintained version of the instructions can be found in the following.

weblinksmap.php documentation

General

Description:
weblinksmap.php allows for the display of web links from Postnuke to be displayed in a Google Map in the PostNuke center frame.
Version:
weblinksmap20060424
Authors:
Manfred Moser
Examples:
can be found at https://www.mosabuam.com/weblinksmap.php and https://www.mosabuam.com/weblinksmap.php?catid=24
and https://www.mosabuam.com/weblinksmap.php?catid=24,26

Disclaimer

This is pretty much a hack. A proper solution would be to add two new field (latitude and longitude) to the web links related tables in PostNuke. Add input for those fields in the administration system and various outputs in the different web links displays. In addition various blocks could be developed to use the data. Feel free to take the code from this component to improve the core.

Initial setup

  • obtain a google map key from http://www.google.com/apis/maps/signup.html
  • insert the key into the variable definition for $googlekey at the top of weblinksmap.php
  • insert the map width into the variable defintion for $mapheight at the top of weblinksmap.php e.g. $mapheight=’400′;
  • insert the map width into the variable defintion for $mapwidth at the top of weblinksmap.php e.g. $mapwidth=’800′;
  • insert the longitude of the initial center point of the map into $initiallongitude at the top of weblinksmap.php e.g. $initiallongitude=’30‘;
  • insert the latitude of the initial center point of the map into $initiallatitude at the top of weblinksmap.php e.g. $initiallatitude=’0′;
  • insert the zoom level for the initial map display into $initialzoomlevel at the top of weblinksmap.php e.g. $initialzoomlevel=’16‘;
  • copy the modified weblinksmap.php into your PostNuke root folder
  • create some map marker links (see below)
  • check out the result at the url http://yourdomain/weblinksmap.php or http://yourdomain/weblinksmap.php?catid=x

Creating map marker links

In your PostNuke admin system go to the WebLinks section and use the Add new link feature.

Add a new link considering the following:

The link title will be used as the link title in the map marker pop up.

The link url will be used as the link url in the map marker pop up. If the supplied link is less than 7 characters (http://) the text will be the title rendered in the map marker pop up without being a link. This is necessary since the web links modules defaults to http:// in the input form and does not allow for empty links. When creating multiple links with invalid links you have to use unique strings (e.g. just use a number), otherwise the weblinks module will not allow you to create the link with an identical link url as another one.

The coordinates for the map marker will be established from the substring {ll=longitude,latitude} within the link description. The easiest way to obtain the coordinates for a specific location is to navigate to the location at http://maps.google.com, click „Link to this page“ and copy the ll=x,y section from the browser url window. Insert this string into description and surround it with {}. See the links section at https://www.mosabuam.com/index.php?name=Web_Links&req=viewlink&cid=24 for examples.

By default all links that contain the string „{ll=“ in the description will be evaluated to be put onto the map. It is also possible to create a map per web links category. To display only the markers in this category on the map use weblinksmap.php?catid=x with x being the id for your category (which you can find out by looking at the url when you navigate to your web links category).

Questions

For questions visit https://www.mosabuam.com or contact manfred@mosabuam.com

Changelog

20060424 – Manfred Moser
release on Postnuke.com revealed that IE is not working, introduced a fix by moving the script to the bottom of the page, new release packaged
20060421 – Manfred Moser
fixed problem with description field from categories table, cleaned up and released new version – thanks again to Frank Schummertz
20060401 – Manfred Moser
implemented use of pnAPI for url parameter usage to improve security after suggestion from Frank Schummertz, released again, also includes feature to use multiple link categories and displays category titles and descriptions
20060316 – Manfred Moser
posted about the release in the Third Party Modules & Blocks forum on the postnuke site
20060316 – Manfred Moser
posted about the release in the Feedback & Suggestions forum on the postnuke site
20060316 – Manfred Moser
release on https://www.mosabuam.com
20060316 – Manfred Moser
implemented feature to render title as normal text if there is no url after suggestion from Werner
20060315 – Manfred Moser
full working first version and documentation from scratch

Dieser Beitrag hat 2 Kommentare

Kommentare sind geschlossen.