Archive for the ‘thydzikGoogleMap’ Category

thydzik Google Map v1.4.7 – inline Wordpress Google Maps

Wednesday, April 15th, 2009

I have released an updated version of thydzik Google Map which allows for colored and variable text markers, see the example below.

Unfortunatley, it now requires FreeType being compiled into PHP. If FreeType is not installed only the default marker and markers A-Z will be useable, with anything else being replaced with the default marker.

Download the latest from the WordPress Plugin Directory.

Dynamic Google Maps markers/icons with PHP

Thursday, March 26th, 2009

I am a avid fan of Google’s Map API, have even have created my own WordPress Google Maps plug-in (thydzikGoogleMap), but one feature that I find lacking are customisable markers, with the need to include an image file for every customisable marker, now if you want a selection of colours and labels this creates a huge image database.

Google has gone in the write step their MapIconMaker allowing very customisable markers using the Charts API marker output. But why not take this a step further and add dynamically generated text as well.

Hence, I provide a little demo of some PHP code that does this that I quickly whipped up. Here are some example markers:
DefaultAZ110PQ69%BEΩ$
(Have a look at the image name)

Now that gets a little boring, how about some color:
DefaultAZ110PQ69%BEΩ$
(Again, have a look at the image name)

Unfortunately, not all symbols work (not sure why, even though they are in the font) and if the symbol doesn’t work it will default to the default bullet (this is done with a modified font file).

Also there may be an issue with alignment. All main characters 0-9 and A-Z; I have added manual offsets, this could be improved.

You will need to download the modified arial font and host it in the same directory.

Update: it looks like in Internet Explorer the transparencies are incorrectly displayed, this is not the case when displayed on a Google Map.

Have a look at the PHP source code below:

<?php
 $color = $_GET['color'];
 if (!$color) {$color = "ff776b";} //default google map color
 $color = str_replace("#", "", $color);
 $string = $_GET['text'];

 //some smarts to prevent hotlinking
 if (!stristr($_SERVER['HTTP_REFERER'], "thydzik.com")) {
 $string = chr(169);
 }
 $font = 'arial';

 //unfortunately we still must do some offsetting
 switch (ord(substr($string,0,1))) {
 case 49: //1
 $offset = -2;
 break;
 case 55: //7
 $offset = -1;
 break;
 case 65: //A
 $offset = 1;
 break;
 case 74: //J
 $offset = -1;
 break;
 case 84: //T
 $offset = 1;
 break;
 case 99: //c
 $offset = -1;
 break;
 case 106: //j
 $offset = 1;
 break;
 }
 if (strlen($string) == 1) {
 $fontsize = 10.5;
 } else if (strlen($string) == 2) {
 $fontsize = 9;
 } else {
 $fontsize = 10.5;
 $offset = 0; //reset offset
 $string = chr(149);
 }

 $bbox = imagettfbbox($fontsize, 0, $font, $string);
 $width = $bbox[2] - $bbox[0] + 1;
 $height = $bbox[1] - $bbox[7] + 1;

 $image_name = "http://chart.apis.google.com/chart?cht=mm&chs=20x34&chco=$color,$color,000000&ext=.png";
 $im = imagecreatefrompng($image_name);
 imageAlphaBlending($im, true);
 imageSaveAlpha($im, true);
 $black = imagecolorallocate($im, 0, 0, 0);

 imagettftext($im, $fontsize, 0, 11 - $width/2 + $offset, 9 + $height/2, $black, $font, $string);

 header("Content-type: image/png");
 imagepng($im);
 imagedestroy($im);
?>

thydzik Google Map version 1.4.6.1

Friday, March 13th, 2009

Latest offering has cleaned up JavaScript, improved error handling, improved RoboGEO handling of XML, but main features are.

  • Icons now support letters ‘A’ to ‘Z’.
  • Non clickable markers if no ‘html’ element is present.

In the below example Marker Z is not clickable.

Download the latest from the WordPress repository.

thydzikGoogleMap v1.4.5 – an inline Google map plugin for Wordpress

Thursday, January 15th, 2009

thydzikGoogleMap v1.4.5 is now available with significant improvements, including

  • The Google Maps Javascript and thydzikGoogleMap Javascript is downloaded only as needed, speeding up page loading of all pages without maps.
  • Removal of <head> code means thydzikGoogleMap will only be present when called.
  • Compressed thydzikGoogleMap code.
  • Multiple maps can now be created in a single post!
  • Map type can be changed from default by providing an additional ‘map type’ parameter.

thydzikGoogleMap produces valid XHTML and allows for easy creation of Google Maps in your Wordpress posts from XML map data.

Grab the latest from the Wordpress repository.

Examples of the newest functionality below:

Using either: Normal, G_NORMAL_MAP, N or left out; i.e. thydzikGoogleMap(example.xml), thydzikGoogleMap will produce a default styled map

Using either: SATELLITE, G_SATELLITE_MAP, S; i.e. thydzikgooglemap(example.xml, 4, S), thydzikGoogleMap will produce a satellite styled map. Note I have included a zoom of 4, and used the abreviation ‘S’.

Using either: HYBRID, G_HYBRID_MAP, H; i.e. tHyDzIkGoOgLeMaP(example.xml,hYbRiD,450,225), thydzikGoolgeMap will produce a hybrid styled map. Note I have included a width and height, and proved that capitalisation is not of concern.

Finally, using either: PHYSICAL, G_PHYSICAL_MAP, P, TERRAIN or T; i.e thydzikGoogleMap(example.xml,TERRAIN), thydzikGoogleMap will produce a terrain styled map.

As always, comments and suggestions welcome. In a future update I will try to incorporate rounded corners :)

thydzikGoogleMap v1.4

Monday, January 12th, 2009

thydzikGoogleMap version 1.4 has been released with two major improvements.

  1. Manual zoom parameter added. Google uses an integer value from 0 to 17 (where 0 is the furthest away), to determine the map’s zoom level, this value can now be incorporated into thydzikGoogleMap as follows: thydzikGoogleMap(example.xml, 4). The zoom is an optional parameter and if left out the automatic zoom calculation will be used as before. The width and height of the map can still be added if desired as thydzikGoogleMap(example.xml, 4, 480, 640) or thydzikGoogleMap(example.xml, 480, 640, 4).
  2. The thydzikGoogleMap code is disabled if the site is viewed from a proxy, i.e. Google cache. Before a user viewing the blog would receive ‘The Google Maps API key used on this web site was registered for a different web site. You can generate a new key for this web site at http://code.google.com/apis/maps/.’ thydzikGoogleMap now detects this and disables the maps.

Example with the new zoom functionality

Future improvements will include

  • Option of choosing Map, Satellite or Terrain
  • Disabling all code if no thydzikGoogleMap are present
  • Creating multiple maps in a single blog post

Grab the latest from the Wordpress repository.

thydzikGoogleMap v1.3.1

Monday, December 1st, 2008

thydzikGoogleMap v1.3.1 has been released, with 2 improvements.

  1. Fixed a problem with cross domain xml files. As reported by Erik on thydzikGoogleMap support forum.
  2. Added improved output for when directly calling thydzikGoogleMap.php

Before Google bots would have picked it up as

Fatal error: Call to undefined function get_option() in /home ...

Now Google will see:

thydzik.com are proudly using the Wordpress plugin thydzikGoogleMap
 to display inline Google maps on their blog.

Where thydzik.com is the Wordpress user’s domain including link.

Finally, a small note about upgrading thydzikGoogleMap. Wordpress has the option of automatically upgrading, which is very handy; unfortunately this overwrites any XML files you may have been storing in the plugin directory. So it is a better idea to keep all your XML maps in a separate location.

thydzikGoogleMap version 1.3.1

thydzikGoogleMap v1.3

Friday, June 13th, 2008

I have finally managed to get Wordpress to update the version number. This problem was due to not updating the version number in the PHP file as well as the readme.txt.

Version 1.3 fixes a problem with thydzikGoogleMap not displaying correctly when a Wordpress blog isn’t located in the domain folder.

I have seen a few users, using thydzikGoogleMap to display a single point or no points at all, thydzikGoogleMap isn’t really for this as it is not worth creating an XML file just for the single point. Plus I believe you can now simply embed a Google map with some simple code.

However, if you want full customization; including lines, numbered points, HTML in a point’s detail, then thydzikGoogleMap is exactly for you.

Comments and suggestions very welcome.

Download thydzikGoogleMap v1.3

Karratha Geocaches (Pilbara, Western Australia)

Tuesday, April 15th, 2008

From time to time I would like to share some of my Australian travels. It doesn’t really fit in technology or projects. Karratha is 1535km north of Perth, Western Australia.

The XML for the map below was made with RoboGEO, which synchronises GPS data with photographs using the timestamp. The XML map data was then displayed as a Google map using my Wordpress plugin thydzikGoogleMap.

One of the features of thydzikGoogleMap is the ability to show XML Google maps, while maintaining the internal links to photographs.