Last active
May 18, 2018 09:41
-
-
Save geoffroycochard/dd51e87c47046a0e8a6025d7acc8b990 to your computer and use it in GitHub Desktop.
Generate list Artifica Widget load
This file contains hidden or 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
/** | |
* Generate Liste from artifica.Widget | |
* @param widget | |
* @param container | |
*/ | |
function generateListFromMap(widget, container) { | |
var onMarkersReady = new Promise(function (resolve, reject) { | |
var checkIfPropertyIsEvaluated = function () { | |
if (widget.markers.length !== 0) { | |
resolve(widget); | |
} else { | |
setTimeout(checkIfPropertyIsEvaluated, 300); | |
} | |
}; | |
setTimeout(checkIfPropertyIsEvaluated, 300); | |
}); | |
onMarkersReady.then(function(widget){ | |
var source = document.getElementById("marker-template").innerHTML; | |
var template = Handlebars.compile(source); | |
$.each(widget.markers, function (k,v) { | |
var context = v.options; | |
var html = template(context); | |
$("#" + container).append(html); | |
}); | |
}, function (error) { | |
}) | |
} |
This file contains hidden or 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
<div id="map-widget"></div> | |
<div id="list-widget"></div> | |
<script> | |
function initWidget() { | |
var widget=new artifica.maps.Widget("#map-widget", { | |
limit : ["fulladdress","fulltimetable","phone","email","site","content","medias"] | |
}); | |
widget.load("markers",["844839","844840","844841","844843","844842","844844","844845","844846","844847","844848","844849","844850","844851","844853","844852","844854","844855","844856","844857","844858","844859","844860","844861","844862","844863","844873","844874","844875","844876","844877"]); | |
widget.load("layers",["6890"]); | |
generateListFromMap(widget, "list-widget"); | |
} | |
</script> | |
<script async defer src="https://ice.artifica.fr/api/js/widgets?key=xxxxxxxxxxxxxxxxx&callback=initWidget"></script> |
This file contains hidden or 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
<script id="marker-template" type="text/x-handlebars-template"> | |
<hr style="margin: 5px 0"/> | |
<a href="#uid-{{id}}" data-toggle="collapse"> | |
<i class="fa fa-plus-square"></i> | |
{{title}} : {{address}} {{postalcode}} {{town}} | |
</a> | |
<div id="uid-{{id}}" class="row search-last-posts-entry collapse"> | |
<div class="entry-search-content"> | |
<p class="row"> | |
<div class="col-md-9"> | |
{{{content}}} | |
</div> | |
<div class="col-md-3"> | |
<ul class=" small"> | |
{{#each phone}} | |
<li><i class="fa fa-phone"></i> {{this}}</li> | |
{{/each}} | |
<li class=""> | |
<a href="mailto:{{email}}" data-toggle="tooltip" data-placement="left" title="{{email}}"> | |
<i class="fa fa-envelope-o"></i> | |
courriel | |
</a> | |
</li> | |
<li> | |
<a target="_blank" href="https://orleans.plan-interactif.com/fr/#!/category/{{tree.parent}}/marker/~{{id}}/detail/@47.900139,1.922143,11"> | |
<i class="fa fa-eye"></i> Voir | |
</a> | |
</li> | |
</ul> | |
</div> | |
</p> | |
</div> | |
</div> | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Difficulté
L'object
widget
n'a pas encore la clé markers de rempli, d'où l'utilisation d'une promesse