thydzikGoogleMap v1.5 – an inline Google map plugin for WordPress

Recently updated and confirmed still working with WordPress 3.0.

The following examples use the included example.xml file.

<markers>
<!-- Marker Z has no html to show nonclickability-->
<marker lat="-31.9554" lng="115.85859"  icon="Z" color="c89bff"/>
<marker lat="-32.053128" lng="115.745869" html="Fremantle"  icon="1" color="6b98ff"/>
<!-- Standard marker with html-->
<marker lat="-32.036036" lng="115.92724" html="Lynwood&lt;br&gt;Residence of the author" color="ffed5c"/>
<marker lat="-31.963013" lng="115.836239" html="Kings Park" icon="KP" color="97ec7d"/>
<!-- Character marker with html that includes link-->
<marker lat="-31.956659" lng="115.869906" html="&lt;a href=&quot;http://perthmint.com.au&quot; rel=&quot;nofollow&quot;&gt;Perth Mint&lt;/a&gt;" icon="$" color="ffffff"/>
<line colour="#0000FF" width="2" opacity="0.75">
	<point lat="-32.027579" lng="115.751266" />
	<point lat="-31.987404" lng="115.769463" />
	<point lat="-31.957697" lng="115.852203" />
	<point lat="-31.963814" lng="115.879326" />
	<point lat="-32.026415" lng="115.942154" />
</line>
</markers>
  • Marker Z – no HTML, nonclickable.
  • Marker 1 – standard maker with some text.
  • Marker Default – no icon defaults to standard Google Maps marker.
  • Marker $ – some symbols can even be displayed on a marker and links in the HTML.
  • Marker KP – up to two characters can be displayed.

The syntax is as follows;

thydzikGoogleMap(example.xml, width, height, zoom, maptype)

where;

  • example.xml is your xml file, and example xml file is included with thdyzikGoogleMap in the plugin directory.
  • width is the optional width parameter, if left out the default width defined in the thydzikGoogleMap options will be used.
  • height is the optional height parameter, if left out the default height defined in the thydzikGoogleMap options will be used.
  • zoom is the optional zoom level from 0 to 17 (0 being the furthest away), if left out zoom will be calculated automatically to fit all points.
  • maptype is the optional map type parameters, which can be (Normal, G_NORMAL_MAP, N), (SATELLITE, G_SATELLITE_MAP, S), (HYBRID, G_HYBRID_MAP, H), (PHYSICAL, G_PHYSICAL_MAP, P, TERRAIN or T) if left out Normal is defined.

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

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’;

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;

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

Reading XML from different folder
The XML can be in any location, as long as the whole path is specified i.e. thydzikgooglemap(http://thydzik.com/geocaching/karratha-mar08/karratha-mar08.xml). Yes, even links in the marker text are preserved.

Reading XML from different domain
The XML can even be on a different domain, as long as the whole path is specified. i.e. thydzikgooglemap(http://sonyaandtravis.com/maps/our-nullarbor-adventure-clare-melbourne08.xml).

  • irssildur

    Hi!

    I like your plugin, but I have a problem with it. I would like to generate the XML output from a MySQL table, but if I insert it like this:

    thydzikgooglemap(kutak.php?megye1=1)

    it doesn’t do anything. I know the XML is correct, because if I copy the output into a foo.xml it works.

    Do you know what should I do to get this work?

    Thanks!

  • http://thydzik.com thydzik

    irssildur,

    Thanks for the positive comments.

    What is the full path of the kutak.php file (so I can test it)? Have you tried using the full path.
    I will have a proper look later tonight.

  • irssildur

    Thanks for the reply!

    It runs on localhost yet, I want to upload to the server after it works.

    Here is the kutak.php (a simple version, just for testing):

    http://openpaste.org/en/22810/

    Here is a sample output:

    http://openpaste.org/en/22811/

    I tried it with both relative and absolute paths, but doesn’t help.

  • irssildur

    Ok, I have tried some debugging.

    If I want to use a PHP file:

    In thydzik-google-map.js in GDownloadURL(..) the markers array is empty (alert(markers.length); gives 0).

  • http://thydzik.com thydzik

    thanks irssildur,

    give me a few days to try things out, I will get back to you.

  • http://thydzik.com thydzik

    irssildur,

    I think I know the problem. I use xml-parser.php to read the (possibly remote) xml file. I have a very basic check which makes sure the parsed xml file ends in an .xml extension.

    To trick this checker, append ‘&.xml” to the end of your php file. So your example would become;
    thydzikgooglemap(kutak.php?megye1=1&.xml)
    This should work.

  • irssildur

    I’ve tried it, but doesn’t help :(

    In xml-proxy.php there is

    if (array_pop(explode(“.”, $url)) ‘xml’) exit;

    If I comment it, doesn’t help either. I wil try debug and, if I have something, I will write you.

  • http://thydzik.com thydzik

    hmmm, that’s strange

    I set up the following dynamic xml file for myself which worked for me.
    http://thydzik.info/example.php?var=true&.xml

    Actually, I think it may be due to the xml header
    < ?xml version="1.0" encoding="UTF-8"?>

  • irssildur

    Anyway, it’s funny because in thydzik-google-map.js in the GDownloadUrl(…) function the condition “if(responseCode==200)” is true, so I think, the JS can load the XML.

  • http://thydzik.com thydzik

    okay, very strange.

    I tested your xml output and it works fine as a static xml file.

    Can you send me an actual static html of the page with the map so I can look at the source.

  • irssildur

    Oh, It Works!!!

    With &.xml after the URL, it finally works. I think (but can be it’s not) the problem was, that my XML looked like not like .

    So it’s ok now! Thanks for the help :)

  • irssildur

    Oh, WordPress eat my XML tags.

    So I used the xml like this: marker… /marker, not like this: marker … /

  • jxdigital

    Hi thydzik,

    Your plugin looks great! However, I can’t seem to get it working. Even not with example.xml. Running 1.5.1 on WP 3.0.1.
    The Google Maps does show up, so it DOES find example.xml, but it doesn’t show any markers. Also it shows the whole world, so the zoom level is at minimum.

    What could I be doing wrong?

  • http://thydzik.com thydzik

    jxdigital,
    Thank you for the feedback.

    If your blog is online, could you please provide a link so I may have a look.

    The issue looks to be that it is not finding example.xml.
    When it doesn’t find the xml zoom is at a minimum and obviously nothing is displayed.

  • jxdigital

    Thanks,

    It looks like it does actually find the XML file. If i put a non-existing filename in thydzikgooglemap(), the map doesn’t show up at all. If I put in example.xml or my own one, it the map itself shows up.
    However, when it does show up, it always shows the minimum zoom level and no data from the XML file.

    Is there anything else that could be wrong here?

  • http://thydzik.com thydzik

    jxdigital,

    You will need to provide a link, it would be a lot easier to debug by seeing it in action.

    When there is a non-existent file name, the plug-in will not produce any Google Map. If the file is found but the xml is malformed it will produce a Google Map with minimum zoom.

    But I don’t understand why this would be happening if you are using the default example.xml.

    Can you please provide a link to your xml and/or your post with the Google Map.

  • jxdigital

    Hi thydzik,

    Thanks for the explanation. Sorry, can’t give a link right now (cannot publish the page until it’s working. I may email you some details?).
    I double checked the XML data and does not seem to be malformed. Also reuploaded example.xml to wp-content/plugins/thydzik-google-map/

    It seems to be something else here… Thought it might have been the theme, but it also happens with default WP theme, and no other plugins activated.
    The directory of the xml file doesn’t have to be writable I presume?
    Also created a new Google Maps API key, but no difference. No errors in Firefox error console. Maybe the server does not meet some special requirements?

  • http://thydzik.com thydzik

    jxdigital,

    The directory of the xml file doesn’t have to be writeable.

    Can you try adding the full url, ie thydzikgooglemap(http://yoursite.com/example.xml)

    my email is ‘mail-a.t-thydzik.com’

    another thing to try is, look at the source code of the page with the map, you will see the following similar string;
    http://thydzik.com/wp-content/plugins/thydzik-google-map/xml-proxy.php?url=6f1282e0a17000e535f04b82e98c8f112b314c8e2ccc725584c8816df43947f8a194a4923a8add4d69326c8d1b54b36f256b9acf5a4d2aa7b651d64ef85bddda28bda522d225b66046905ce8e14b2ecc7fa24e5e640e95450b4d4f1030996b34

    paste this into your browser and confirm you see the xml.

  • jxdigital

    Hi,

    Tried adding full URL to xml, still no data in the map.
    A string like yours is indeed in the source of the page. Going to that URL results indeed in the correct (example) XML file, so I still don’t think that is the problem here?

  • http://thydzik.com thydzik

    jxdigital,

    I am now stumped.

    When you get a chance, please send me a link to the post with the map, I will have a further look.

    second thought, what other plugins are you using?

  • http://thydzik.com thydzik

    jxdigital, any update if you could make your site with the plugin issue plublic?