DEPRECATION WARNING

This documentation is not using the current rendering mechanism and is probably outdated. The extension maintainer should switch to the new system. Details on how to use the rendering mechanism can be found here.

EXT: Netcos Google Map fixed

Created:2007-10-05T16:19:04
Changed:2009-04-15T14:19:24
Author:Bernd Warken
Email:be.warken@netcos.de
Info 3:
Info 4:

EXT: Netcos Google Map fixed

by Bernd Warken at netcos AG

Extension Key: netcos_googlemap_fixed

Copyright 2007,2008 Bernd Warken, <be.warken@netcos.de>

This document is published under the General Public License ( GPL ) version 3available from :underline:`http://www.gnu.org/licenses/gpl.html <http://www.gnu.org/licenses/gpl.html>`_

The content of this document is related to TYPO3- a GNU/GPL CMS/Framework available from http://www.typo3.com

Table of Contents

EXT: Netcos Google Map fixed 1

a

EXT: Netcos Google Map fixed 1

Introduction 1

What does it do? 1

Technical Details 1

b

Installation 2

Google Map Key 2

Configuration 2

Geocoding 3

Brute Force: changing of a Source Code File 3

Make it run 4

Introduction

What does it do?

This TYPO3 extension provides the possibility to display a Google Map within a TYPO3 installation. You can change the size of the map, its center, its zoom level, and its map type in a TypoScript configuration. You do not need to change any file of the extension source code. You can only use a single map on each page, but you can display it as many times as you like. By changing the TypoScript configuration, you can display different maps on different pages.

To display several maps on a single page, use the extension netcos_googlemap .

Technical Details

This extension was developed and tested on TYPO3 version 4.1.2 up to 4.1.6. It might run on other TYPO3 versions as well, but I did not test it.

At http://www.netcos-typo3.de , you can find some TYPO3 tutorials on the extensions written at netcos AG. One of these is about this extension. It mentions the details of its generation and the background of its source code.

Installation

You can easily install this extension in the Ext Manager without problems. But in order to use it, you should add a TypoScript configuration.

Google Map Key

First you need a URL for your website or domain. For this URL, you can get a key for your Google map at http://google.com/apis/maps . This key may be stored in a constant within the TypoScript template, e.g.

google_map_key = ABQIAAAARokCoxWjWuwH4eEaCOyBkBQuBzwEBiC_X9c-oZXEt-

a

google_map_key = ABQIAAAARokCoxWjWuwH4eEaCOyBkBQuBzwEBiC_X9c-oZXEt- cQ-gHLphTNVyn1sryGsgMB2Ixb3PPPObdpOw

Remove the line break. This is just an example, it won't work.

A script for the Google map must be called by the following commands in TypoScript template setup:

page.headerData.900 = TEXT

a

page.headerData.900 = TEXT

page.headerData.900.value (

<script src="http://maps.google.com/maps?file=api&v=2&key={$google_map_key}"

type="text/javascript"></script>

)

You are free to choose a different value than 900. You just have to be sure that no other page.headerData exists with the same value.

Configuration

You need to add 6 fields to the configuration of a TypoScript setup (constants won't work). For example, you can use the following configuration:

plugin.tx_netcosgooglemapfixed_pi1 {

a

plugin.tx_netcosgooglemapfixed_pi1 {

width = 500

height = 600

latitude = 48.2

longitude = 11.2

zoom_level = 15

map_type = NORMAL

}

The value of width is a positive integer.

The value of height is a positive integer.

The width and the height are values in pixels of the frame in which the map is drown. Do not add any characters for the unit, etc.

The value of latitude is a decimal number (float) with a dot as separating character. It signifies the latitude of the position in which the map is centered. Do not use arc units.

The value of longitude is a decimal number (float) with a dot as separating character. It signifies the longitude of the position in which the map is centered. Do not use arc units.

Latitude and longitude of a position can be determined in the internet, e.g. at the Google map; for a description, see Google Code FAQ - Tutorial: Creating Your First Map at `http://code.google.com/support/bin/answer.py?answer=74725&topic=11364 <http://code.google.com/support/bin/answer.py?answer=74725&topic=11364 >`_ . For other sites, look at Google for something like latitude longitude finder . For example, http://www.satsig.net/maps/lat- long-finder.htm will do.

An exactness of about 5 decimals for both values is sufficient for most positions.

The zoom level is a positive integer less than 20. It regulates the details shown on the map.

  • Zoom level 1 displays the whole globe.
  • Zoom level 13 displays a village or district.
  • Zoom level 15 displays a street.
  • Zoom level 19 displays a house.

The map type is a string that regulates the display mode of the map. Google has the following modes:

  • NORMAL displays a map without satellite pictures.
  • SATELLITE displays the map as a satellite picture.
  • HYBRID displays the satellite photo together with streets and their names taken from the normal map.

Geocoding

The latitude and the longitude must be determined. You can do this with many sites you find at the Google search engine. But Google map provides this feature, too. You find a description in a Google map API FAQ called Tutorial: Creating Your First Map at section 3. This is available at `http://code.google.com/support/bin/answer.py?answer=74725&topic=11364 <http://code.google.com/support/bin/answer.py?answer=74725&topic=11364 >`_ .

Load the place for your latitude and longitude at the normal Google map in the internet. Then click the button Link to this page at the top right. This produces a form with one or more information fields. Choose the 2 numbers at the parameter ll (double L). These are decimals for the latitude and the longitude. You can use these numbers for the configuration of this extension.

Brute Force: changing of a Source Code File

It is no longer necessary to change any source code file. So you can ignore this section. But if you want to change the source code anyway just go ahead.

For proper working, you must set and uncomment 6 variables in the extension source code file pi1/class.tx_netcosgooglemapfixed_pi1.php .

In order to be allowed to change an extension source code file you have to disable the button for ` noEdit <http://www.schulungsraum-muenchen.de/typo3/mod/tools/em/i ndex.php?CMD%5BshowExt%5D=netcos_googlemap_fixed&CMD%5BdownloadFile%5D =%2Fsites%2Fncwww%2Fdocs%2Ftypo3conf%2Fext%2Fnetcos_googlemap_fixed%2F pi1%2Fclass.tx_netcosgooglemapfixed_pi1.php>`_ in the TYPO3 ` Install <http://www .schulungsraum-muenchen.de/typo3/mod/tools/em/index.php?CMD%5BshowExt% 5D=netcos_googlemap_fixed&CMD%5BdownloadFile%5D=%2Fsites%2Fncwww%2Fdoc s%2Ftypo3conf%2Fext%2Fnetcos_googlemap_fixed%2Fpi1%2Fclass.tx_netcosgo oglemapfixed_pi1.php>`_ tool.

After having installed the extension, you can go to ` Loaded extensions <http://www .schulungsraum-muenchen.de/typo3/mod/tools/em/index.php?CMD%5BshowExt% 5D=netcos_googlemap_fixed&CMD%5BdownloadFile%5D=%2Fsites%2Fncwww%2Fdoc s%2Ftypo3conf%2Fext%2Fnetcos_googlemap_fixed%2Fpi1%2Fclass.tx_netcosgo oglemapfixed_pi1.php>`_ in the ` Ext Manager <http://www.schulungsraum-muenchen.de/typo3/mod/tools/e m/index.php?CMD%5BshowExt%5D=netcos_googlemap_fixed&CMD%5BdownloadFile %5D=%2Fsites%2Fncwww%2Fdocs%2Ftypo3conf%2Fext%2Fnetcos_googlemap_fixed %2Fpi1%2Fclass.tx_netcosgooglemapfixed_pi1.php>`_ . There you click the name of the extension ` Netcos Google Map fixed <http://www.schulungsraum-muenchen.de/typo3 /mod/tools/em/index.php?CMD%5BshowExt%5D=netcos_googlemap_fixed&CMD%5B downloadFile%5D=%2Fsites%2Fncwww%2Fdocs%2Ftypo3conf%2Fext%2Fnetcos_goo glemap_fixed%2Fpi1%2Fclass.tx_netcosgooglemapfixed_pi1.php>`_ . Instead of ` Information, <http://www.schulungsraum-muenchen.de/typo3/mod/tools/em/index.php?CMD %5BshowExt%5D=netcos_googlemap_fixed&CMD%5BdownloadFile%5D=%2Fsites%2F ncwww%2Fdocs%2Ftypo3conf%2Fext%2Fnetcos_googlemap_fixed%2Fpi1%2Fclass. tx_netcosgooglemapfixed_pi1.php>`_ you choose the menu button ` Edit files <http://www .schulungsraum-muenchen.de/typo3/mod/tools/em/index.php?CMD%5BshowExt% 5D=netcos_googlemap_fixed&CMD%5BdownloadFile%5D=%2Fsites%2Fncwww%2Fdoc s%2Ftypo3conf%2Fext%2Fnetcos_googlemap_fixed%2Fpi1%2Fclass.tx_netcosgo oglemapfixed_pi1.php>`_ . Then all files of this extension are shown. You choose ` Edit file <http://www.schulungsraum-muenchen.de/typo3/mod/tools/em/index.php?CMD %5BshowExt%5D=netcos_googlemap_fixed&CMD%5BdownloadFile%5D=%2Fsites%2F ncwww%2Fdocs%2Ftypo3conf%2Fext%2Fnetcos_googlemap_fixed%2Fpi1%2Fclass. tx_netcosgooglemapfixed_pi1.php>`_ `of <http://www.schulungsraum-muenc hen.de/typo3/mod/tools/em/index.php?CMD%5BshowExt%5D=netcos_googlemap_ fixed&CMD%5BdownloadFile%5D=%2Fsites%2Fncwww%2Fdocs%2Ftypo3conf%2Fext% 2Fnetcos_googlemap_fixed%2Fpi1%2Fclass.tx_netcosgooglemapfixed_pi1.php >`_ ` pi1/class.tx_netcosgooglemapfixed_pi1.php <http://www .schulungsraum-muenchen.de/typo3/mod/tools/em/index.php?CMD%5BshowExt% 5D=netcos_googlemap_fixed&CMD%5BdownloadFile%5D=%2Fsites%2Fncwww%2Fdoc s%2Ftypo3conf%2Fext%2Fnetcos_googlemap_fixed%2Fpi1%2Fclass.tx_netcosgo oglemapfixed_pi1.php>`_ . The editor opens for this file.

In this file, you have to change the 6 variables ` $width <http://www.schulungsraum-muenchen .de/typo3/mod/tools/em/index.php?CMD%5BshowExt%5D=netcos_googlemap_fix ed&CMD%5BdownloadFile%5D=%2Fsites%2Fncwww%2Fdocs%2Ftypo3conf%2Fext%2Fn etcos_googlemap_fixed%2Fpi1%2Fclass.tx_netcosgooglemapfixed_pi1.php>`_ , ` $height <http://www .schulungsraum-muenchen.de/typo3/mod/tools/em/index.php?CMD%5BshowExt% 5D=netcos_googlemap_fixed&CMD%5BdownloadFile%5D=%2Fsites%2Fncwww%2Fdoc s%2Ftypo3conf%2Fext%2Fnetcos_googlemap_fixed%2Fpi1%2Fclass.tx_netcosgo oglemapfixed_pi1.php>`_ , ` $latitude <http://www.schulungsraum-muenchen.de/typo3/mod/tools/em/ index.php?CMD%5BshowExt%5D=netcos_googlemap_fixed&CMD%5BdownloadFile%5 D=%2Fsites%2Fncwww%2Fdocs%2Ftypo3conf%2Fext%2Fnetcos_googlemap_fixed%2 Fpi1%2Fclass.tx_netcosgooglemapfixed_pi1.php>`_ , ` $longitude <http://www.schulungsraum-muen chen.de/typo3/mod/tools/em/index.php?CMD%5BshowExt%5D=netcos_googlemap _fixed&CMD%5BdownloadFile%5D=%2Fsites%2Fncwww%2Fdocs%2Ftypo3conf%2Fext %2Fnetcos_googlemap_fixed%2Fpi1%2Fclass.tx_netcosgooglemapfixed_pi1.ph p>`_ , ` $zoom_level <http://www.schulungsraum-muenchen.de/typo3/mod/tools/em/index.php?CMD %5BshowExt%5D=netcos_googlemap_fixed&CMD%5BdownloadFile%5D=%2Fsites%2F ncwww%2Fdocs%2Ftypo3conf%2Fext%2Fnetcos_googlemap_fixed%2Fpi1%2Fclass. tx_netcosgooglemapfixed_pi1.php>`_ , and ` $map_type <http://www.schulungsraum-muenchen.de/typo3/mod /tools/em/index.php?CMD%5BshowExt%5D=netcos_googlemap_fixed&CMD%5Bdown loadFile%5D=%2Fsites%2Fncwww%2Fdocs%2Ftypo3conf%2Fext%2Fnetcos_googlem ap_fixed%2Fpi1%2Fclass.tx_netcosgooglemapfixed_pi1.php>`_ . They are kept in the ` function main <http://www.schulungsraum-muenchen.de/typo3/mod/tools/em/index.php?CMD %5BshowExt%5D=netcos_googlemap_fixed&CMD%5BdownloadFile%5D=%2Fsites%2F ncwww%2Fdocs%2Ftypo3conf%2Fext%2Fnetcos_googlemap_fixed%2Fpi1%2Fclass. tx_netcosgooglemapfixed_pi1.php>`_ . For each variable line, use the following format:

The predefined area in this file is <http://www.schulungsraum-muenche n.de/typo3/mod/tools/em/index.php?CMD%5BshowExt%5D=netcos_googlemap_fi xed&CMD%5BdownloadFile%5D=%2Fsites%2Fncwww%2Fdocs%2Ftypo3conf%2Fext%2F netcos_googlemap_fixed%2Fpi1%2Fclass.tx_netcosgooglemapfixed_pi1.php> _

/*

a

/*

$width = 400;

$height = 400;

$latitude = 48.1456;

$longitude = 11.6156;

$zoom_level = 15;

$map_type = NORMAL;

*/

You must uncomment it and adapt the values of the variables. The default values are for a map centered at ` netcos AG <http://www.schulungsraum-muenchen.de/typo3/mod/t ools/em/index.php?CMD%5BshowExt%5D=netcos_googlemap_fixed&CMD%5Bdownlo adFile%5D=%2Fsites%2Fncwww%2Fdocs%2Ftypo3conf%2Fext%2Fnetcos_googlemap _fixed%2Fpi1%2Fclass.tx_netcosgooglemapfixed_pi1.php>`_ in Munich, Germany. You definitely will use different values for your purpose.

The names of the variables and the types of their content are equal to the TypoScript configuration. So see section ` Configuration <http://www.schulungsraum-m uenchen.de/typo3/mod/tools/em/index.php?CMD%5BshowExt%5D=netcos_google map_fixed&CMD%5BdownloadFile%5D=%2Fsites%2Fncwww%2Fdocs%2Ftypo3conf%2F ext%2Fnetcos_googlemap_fixed%2Fpi1%2Fclass.tx_netcosgooglemapfixed_pi1 .php>`_ for more details.

Make it run

To use this extension in a page you have to add its plugin when creating a page in the module Page . You just choose this plugin for a page and the map is drawn with the values you entered in your configuration. For that, your URL and the corresponding Google Map key must be alright.

If the map is not drawn clear the cache in your TYPO3 installation and in your web browser. In many browsers, this can be done by CTRL-F5. If your map is still not drawn please check the TypoScript configuration and the setting of your Google map key.