0

I would like to insert the Google Map API inside an xhtml jsf page. The probleme is that when i insert the tag :

<script src="https://maps.googleapis.com/maps/api/js?key=MyAPIKey&libraries=visualization&callback=initMap" async defer></script>

The server give me the error :

Error Parsing /listUsers.xhtml: Error Traced[line: 21] Reference to the entity "libraries" must end with ';'.

The error happens specificaly when I add the src attribute in the script tag.

I'm sure that the script is the issue because the xhtml page is very simple :

<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
      xmlns:f="http://xmlns.jcp.org/jsf/core">
    <h:head>
        <title>Google Map API on xhtml</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0"/>

    </h:head>

    <h:body>


    <script src="https://maps.googleapis.com/maps/api/js?key=MyAPIKey&libraries=visualization&callback=initMap" async defer></script>
    </h:body>
</html>

I'm sure the script is working since i manage to display the Google Map on a regular html page.

What should I do to include the map wiithout having trouble ?

Kaviranga
  • 576
  • 2
  • 10
  • 24
Omegaspard
  • 1,828
  • 2
  • 24
  • 52
  • in the browser developer tools console, what does `document.getElementsByTagName("head")[0]` return? One problem could be that there is no `head` element ... which is where that google api script loads other scripts! Try adding an empty `` element before your `` – Jaromanda X Jan 24 '17 at 01:13
  • There is élément, doesn't it count ? – Omegaspard Jan 24 '17 at 01:32
  • Did you try what I suggested as the first sentence in the comment? No, it doesn't count – Jaromanda X Jan 24 '17 at 01:33
  • Adding the head didn't work. And i can't print the content of document.getElementByTagName(head) because of the Jee error. But I inspect the page i can see a script tag with Google js function inside. – Omegaspard Jan 24 '17 at 01:44
  • `and i can't print the content of document.getElementByTagName(head)` - two errors in that ... it's getElementsByTagName (the s is important) and it's the string "head" not a variable name head ... and your error wouldn't stop the browser developer tools console from giving you that information – Jaromanda X Jan 24 '17 at 01:46

0 Answers0