google maps

6 views
Skip to first unread message

jack

unread,
Oct 22, 2010, 12:08:15 AM10/22/10
to Lift
What is the best way to load a google map into a lift page?

Peter Robinett

unread,
Oct 22, 2010, 1:38:13 PM10/22/10
to Lift
Can you give us more information, Jack? That's a VERY broad question
and thus hard to answer. You could do several different ways, from
HTML to Javascript to either of those generated by Scala code.

Peter

Derek Chen-Becker

unread,
Oct 22, 2010, 3:36:05 PM10/22/10
to lif...@googlegroups.com
I agree that it's pretty broad, but a few things to note in general about Google (and a lot of other) JavaScript APIs:

  1. Lift defaults to XHTML, which Google Maps won't work with. Override this via LiftRules.determineContentType (can specify HTML for a specific request path) or LiftRules.useXhtmlMimeType (global override)
  2. If you're going to insert API urls, etc into templates from your Scala code, remember that you need to wrap them in scala.xml.Unparsed if they contain things like ampersands (&). Otherwise, Scala's XML lib will escape everything and you'll end up with URLs like "http://foo.com?test=1&bar=2" instead of "http://foo.com?test=1&bar=2"
Derek

--
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to lif...@googlegroups.com.
To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.


Mario

unread,
Nov 1, 2010, 3:43:16 PM11/1/10
to Lift
I have implemented part 1 and the google maps is working great.
However, when I include my maps api key
e.g. <script src="http://maps.google.com/maps?
file=api&v=2&key=mykey&sensor=false" type="text/javascript" />
in one of the .html files, it causes liftweb to break with the
following output:

java.lang.RuntimeException: Expected
';'scala.xml.parsing.MarkupParserCommon
$class.takeUntilChar(MarkupParserCommon.scala:88)
scala.xml.parsing.MarkupParserCommon
$class.normalizeAttributeValue(MarkupParserCommon.scala:148) ...

I think that this is somehow related to point 2 from the previous
post. What do you think?


On Oct 22, 8:36 pm, Derek Chen-Becker <dchenbec...@gmail.com> wrote:
> I agree that it's pretty broad, but a few things to note in general about
> Google (and a lot of other) JavaScript APIs:
>
>    1. Lift defaults to XHTML, which Google Maps won't work with. Override
>    this via LiftRules.determineContentType (can specify HTML for a specific
>    request path) or LiftRules.useXhtmlMimeType (global override)
>    2. If you're going to insert API urls, etc into templates from your Scala
>    code, remember that you need to wrap them in scala.xml.Unparsed if they
>    contain things like ampersands (&). Otherwise, Scala's XML lib will escape
>    everything and you'll end up with URLs like "
>    http://foo.com?test=1&bar=2" instead of "http://foo.com?test=1&bar=2"
>
> Derek
>
> On Fri, Oct 22, 2010 at 11:38 AM, Peter Robinett <pe...@bubblefoundry.com>wrote:
>
>
>
>
>
>
>
> > Can you give us more information, Jack? That's a VERY broad question
> > and thus hard to answer. You could do several different ways, from
> > HTML to Javascript to either of those generated by Scala code.
>
> > Peter
>
> > On Oct 22, 6:08 am, jack <j...@whirld.com> wrote:
> > > What is the best way to load a google map into a lift page?
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Lift" group.
> > To post to this group, send email to lif...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > liftweb+u...@googlegroups.com<liftweb%2Bunsu...@googlegroups.com >
> > .

David Pollak

unread,
Nov 1, 2010, 4:06:18 PM11/1/10
to lif...@googlegroups.com
On Mon, Nov 1, 2010 at 12:43 PM, Mario <mario...@gmail.com> wrote:
I have implemented part 1 and the google maps is working great.
However, when I include my maps api key
e.g. <script src="http://maps.google.com/maps?
file=api&v=2&key=mykey&sensor=false" type="text/javascript" />
in one of the .html files, it causes liftweb to break with the
following output:

java.lang.RuntimeException: Expected
';'scala.xml.parsing.MarkupParserCommon
$class.takeUntilChar(MarkupParserCommon.scala:88)
scala.xml.parsing.MarkupParserCommon
$class.normalizeAttributeValue(MarkupParserCommon.scala:148) ...

I think that this is somehow related to point 2 from the previous
post. What do you think?

Attributes must be properly XML encoded:
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=mykey&amp;sensor=false" type="text/javascript" />

 
To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.




--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Blog: http://goodstuff.im
Surf the harmonics

Mario

unread,
Nov 1, 2010, 5:29:19 PM11/1/10
to Lift
Yep, that does it. Thank you!

On Nov 1, 9:06 pm, David Pollak <feeder.of.the.be...@gmail.com> wrote:
> On Mon, Nov 1, 2010 at 12:43 PM, Mario <mario.lu...@gmail.com> wrote:
> > I have implemented part 1 and the google maps is working great.
> > However, when I include my maps api key
> > e.g. <script src="http://maps.google.com/maps?
> > file=api&v=2&key=mykey&sensor=false" type="text/javascript" />
> > in one of the .html files, it causes liftweb to break with the
> > following output:
>
> > java.lang.RuntimeException: Expected
> > ';'scala.xml.parsing.MarkupParserCommon
> > $class.takeUntilChar(MarkupParserCommon.scala:88)
> > scala.xml.parsing.MarkupParserCommon
> > $class.normalizeAttributeValue(MarkupParserCommon.scala:148) ...
>
> > I think that this is somehow related to point 2 from the previous
> > post. What do you think?
>
> Attributes must be properly XML encoded:
> <script src="http://maps.google.com/maps?file=api&v=2&key=mykey&sensor..."
> > <liftweb%2Bunsu...@googlegroups.com<liftweb%252Bunsubscribe@googlegroup s.com>>
> > > > .
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/liftweb?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Lift" group.
> > To post to this group, send email to lif...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > liftweb+u...@googlegroups.com<liftweb%2Bunsu...@googlegroups.com >
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/liftweb?hl=en.
>
> --
> Lift, the simply functional web frameworkhttp://liftweb.net
> Beginning Scalahttp://www.apress.com/book/view/1430219890
Reply all
Reply to author
Forward
0 new messages