JavaScript must be enabled in order for you to use Google Maps. However, it seems JavaScript is either disabled or not supported by your browser. To view Google Maps, enable JavaScript by changing your browser options, and then try again.

Michael Tyler

KML Travel Blog

Thursday, March 06, 2008

remove line break characters

preg_replace to get rid of those pesky line break characters.

Particularly for Google Maps bubble's which take an aversion to non-ASCII chars so as to stop a map rendering altogether.

Non-ACSII characters
This piece of code should be applied when generating a Google Map using any quantity of user generated material.

function removelinebreaks($string)
{
return preg_replace('/[\r\n\t]/e', ' ', $string);
}

Also make sure you trim your bubbles, and if you're particularly nervous check the htmlentities and CDATA[ declarations also.

Makes for happier bubbles :)

Labels: , ,

Links to this post

0 Comments:

Post a Comment

<< Home

Links to this post:

Create a Link