1

When trying to implement the google maps API script in default_head_blocks.xml

<script src="https://maps.googleapis.com/maps/api/js?key=mykey&libraries=places" src_type="url"/>

it doesn't load the google maps script. But when I tried to replace the & with "&amp;" I get the following error:

1 exception(s): Exception #0 (Exception): Warning: simplexml_load_string(): Entity: line 503: parser error : EntityRef: expecting ';' in vendor\magento\framework\View\Model\Layout\Merge.php on line 493

Exception #0 (Exception): Warning: simplexml_load_string(): Entity: line 503: parser error : EntityRef: expecting ';' in vendor\magento\framework\View\Model\Layout\Merge.php on line 493

#0 [internal function]: Magento\Framework\App\ErrorHandler->handler(2, 'simplexml_load_...', 'C:\\wamp\\www\\DLB...', 493, Array)
#1 vendor\magento\framework\View\Model\Layout\Merge.php(493): simplexml_load_string('<layouts xmlns:...', 'Magento\\Framewo...')
#2 vendor\magento\framework\View\Model\Layout\Merge.php(716): Magento\Framework\View\Model\Layout\Merge->_loadXmlString('<layouts xmlns:...')
#3 vendor\magento\framework\View\Model\Layout\Merge.php(633): Magento\Framework\View\Model\Layout\Merge->_loadFileLayoutUpdatesXml()
#4 var\generation\Magento\Framework\View\Model\Layout\Merge\Interceptor.php(232): Magento\Framework\View\Model\Layout\Merge->getFileLayoutUpdatesXml()
#5 vendor\magento\framework\View\Model\Layout\Merge.php(527): Magento\Framework\View\Model\Layout\Merge\Interceptor->getFileLayoutUpdatesXml()
#6 vendor\magento\framework\View\Model\Layout\Merge.php(506): Magento\Framework\View\Model\Layout\Merge->_fetchPackageLayoutUpdates('default')
#7 vendor\magento\framework\View\Model\Layout\Merge.php(434): Magento\Framework\View\Model\Layout\Merge->_merge('default')
#8 var\generation\Magento\Framework\View\Model\Layout\Merge\Interceptor.php(193): Magento\Framework\View\Model\Layout\Merge->load(Array)
#9 vendor\magento\framework\View\Layout\Builder.php(86): Magento\Framework\View\Model\Layout\Merge\Interceptor->load()
#10 vendor\magento\framework\View\Layout\Builder.php(63): Magento\Framework\View\Layout\Builder->loadLayoutUpdates()
#11 vendor\magento\framework\View\Page\Config.php(197): Magento\Framework\View\Layout\Builder->build()
#12 vendor\magento\framework\View\Page\Config.php(207): Magento\Framework\View\Page\Config->build()
#13 vendor\magento\framework\View\Result\Page.php(227): Magento\Framework\View\Page\Config->publicBuild()
#14 vendor\magento\framework\View\Result\Layout.php(164): Magento\Framework\View\Result\Page->render(Object(Magento\Framework\App\Response\Http\Interceptor))
#15 vendor\magento\framework\Interception\Interceptor.php(74): Magento\Framework\View\Result\Layout->renderResult(Object(Magento\Framework\App\Response\Http\Interceptor))
#16 vendor\magento\framework\Interception\Chain\Chain.php(70): Magento\Framework\View\Result\Page\Interceptor->___callParent('renderResult', Array)
#17 vendor\magento\framework\Interception\Chain\Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...', 'renderResult', Object(Magento\Framework\View\Result\Page\Interceptor), Array, 'result-varnish-...')
#18 vendor\magento\module-page-cache\Model\Controller\Result\VarnishPlugin.php(74): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Response\Http\Interceptor))
#19 vendor\magento\framework\Interception\Chain\Chain.php(67): Magento\PageCache\Model\Controller\Result\VarnishPlugin->aroundRenderResult(Object(Magento\Framework\View\Result\Page\Interceptor), Object(Closure), Object(Magento\Framework\App\Response\Http\Interceptor))
#20 vendor\magento\framework\Interception\Interceptor.php(138): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...', 'renderResult', Object(Magento\Framework\View\Result\Page\Interceptor), Array, 'result-builtin-...')
#21 vendor\magento\module-page-cache\Model\Controller\Result\BuiltinPlugin.php(67): Magento\Framework\View\Result\Page\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Response\Http\Interceptor))
#22 vendor\magento\framework\Interception\Interceptor.php(142): Magento\PageCache\Model\Controller\Result\BuiltinPlugin->aroundRenderResult(Object(Magento\Framework\View\Result\Page\Interceptor), Object(Closure), Object(Magento\Framework\App\Response\Http\Interceptor))
#23 var\generation\Magento\Framework\View\Result\Page\Interceptor.php(130): Magento\Framework\View\Result\Page\Interceptor->___callPlugins('renderResult', Array, Array)
#24 vendor\magento\framework\App\Http.php(139): Magento\Framework\View\Result\Page\Interceptor->renderResult(Object(Magento\Framework\App\Response\Http\Interceptor))
#25 vendor\magento\framework\App\Bootstrap.php(258): Magento\Framework\App\Http->launch()
#26 index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http))

Any suggestions?

2

Try replace src attribute to:

https://maps.googleapis.com/maps/api/js?key=mykey&amp;amp;amp;libraries=places

It is work for me fine.

  • Replacing a & with &amp; should work. Probably Magento is doing some preprocessing, so it needs &amp;amp;? The third amp; in this answer is to keep &amp; in the final output to have the ampersand escaped properly inside the src attribute – 7ochem Apr 9 '18 at 8:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.