Skip to main content
December 2, 2009
Question

Single quotes and google maps

  • December 2, 2009
  • 1 reply
  • 911 views

Google maps does not like single quotes from db field values.  When trying to display the word "People's Gardens" in a google map popup balloon it did not run.  Take the single quote out and it is fine.

I'm trying to figure out what characters I need to avoid, other than the single quote, in order to make the google maps api happy.

I tried to strip out that character using JSStringFormat but that did not work.  I ended up just using Replace() but was wondering if there's a better way to eliminate any/all problematic characters and also what those characters are.

Thanks.

P.S. Coldfusion rules and I don't care what you Java developers say.

    This topic has been closed for replies.

    1 reply

    ilssac
    Inspiring
    December 2, 2009

    It's not Google Maps, its JavaScript which is the language in which you program the Google Map API that cares.

    The solution is to escape the single quotes in the maner that JavaScript likes, which the JSStringFormat() function is designed to handle.

    JSStringFormat

    http://livedocs.adobe.com/coldfusion/8/htmldocs/index.html

    Description

    Escapes special JavaScript characters, such as single-quotation mark, double-quotation mark, and newline.

    December 2, 2009

    Well I partially agree.  I have tried to use that but perhaps its tripping up on something other than the single quote?  The reason I say this is because I'm trying to use both the autosuggest feature and google maps and both have the JSStringFormat function attempting to strip out "bad" characters but it is not working.

    ilssac
    Inspiring
    December 2, 2009

    Then you need to explain what "not working" means?  Errors?  What are the errors?  Improper behavior?  What is the behavior?  What is the desired behavior?

    Simple code samples and|or links to running examples often help as well.