forked from ezsystems/ezplatform-demo
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DEMO-252: Switch to OpenStreet maps on eZ Platform OE demo (ezsystems…
- Loading branch information
Showing
7 changed files
with
140 additions
and
265 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
app/Resources/views/themes/tastefulplanet/parts/map.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<div class="places_map_data" id="{{ map_container_id }}_map_data" hidden> | ||
{% if contentArray|length > 0 %} | ||
{% for content in contentArray %} | ||
<span class="map_place" | ||
data-lat="{{ ez_field_value( content, 'location' ).latitude }}" | ||
data-lng="{{ ez_field_value( content, 'location' ).longitude }}" | ||
data-name="{{ ez_render_field(content, "name")|striptags }}"> | ||
</span> | ||
{% endfor %} | ||
{% endif %} | ||
</div> | ||
|
||
<script type="text/javascript"> | ||
document.addEventListener("DOMContentLoaded", function(event) { | ||
(function (global, doc) { | ||
// if the page is not using iframe - load map | ||
if (global === global.parent) { | ||
global.mapLoader('#{{ map_container_id }}'); | ||
return; | ||
} | ||
// wait for DOM to be ready | ||
let stateCheck = setInterval(() => { | ||
if (doc.readyState === 'complete') { | ||
clearInterval(stateCheck); | ||
global.mapLoader('#{{ map_container_id }}'); | ||
} | ||
}, 100); | ||
})(window, document); | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
/** | ||
* @copyright Copyright (C) eZ Systems AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
namespace AppBundle\Twig; | ||
|
||
use eZ\Publish\API\Repository\Values\Content\Search\SearchHit; | ||
use eZ\Publish\API\Repository\Values\Content\Search\SearchResult; | ||
use Twig_Extension; | ||
use Twig_Function; | ||
|
||
/** | ||
* Twig helper for extract SearchResult object and returns array | ||
*/ | ||
class SearchResultExtractorExtension extends Twig_Extension | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getName() | ||
{ | ||
return 'app.search_result_extract'; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getFunctions() | ||
{ | ||
return [ | ||
new Twig_Function('app_search_result_extract', [$this, 'extractSearchResult']) | ||
]; | ||
} | ||
|
||
/** | ||
* Returns extracted SearchResult object as array | ||
* | ||
* @param SearchResult $searchResult | ||
* @return array | ||
*/ | ||
public function extractSearchResult(SearchResult $searchResult): array | ||
{ | ||
return array_map(function (SearchHit $searchHit) { | ||
return $searchHit->valueObject; | ||
}, $searchResult->searchHits); | ||
} | ||
} |
Oops, something went wrong.