Created
June 13, 2018 07:51
-
-
Save v-ruiz/3af4665ea6979b4a754d5ae59e7a17b4 to your computer and use it in GitHub Desktop.
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
var search = instantsearch({ | |
appId: 'YI8X4LI0XI', | |
apiKey: '472b04f669a69e8a0cfa12824931c606', // search only API key, no ADMIN key | |
indexName: 'DEV_INDEX_POST_HELPER_2', | |
// urlSync: true, | |
routing: true, | |
enableRefineOnMapMove: true, | |
searchParameters: { | |
hitsPerPage: 25, | |
} | |
}); | |
const placesElemeent = document.getElementById('search_address') | |
const mapElement = document.getElementById('map') | |
search.addWidget( | |
placesInstantsearchWidget({ | |
container: placesElemeent, | |
countries: 'fr' | |
}) | |
); | |
search.addWidget( | |
instantsearch.widgets.hits({ | |
container: document.querySelector('#hits'), | |
templates: { | |
item: document.getElementById('hit-template').innerHTML | |
} | |
}) | |
); | |
search.addWidget( | |
instantsearch.widgets.geoSearch({ | |
googleReference: window.google, | |
container: mapElement, | |
radius: 20000, | |
enableGeolocationWithIP: false, | |
enableClearMapRefinement: false, | |
customHTMLMarker: { | |
template: function(e) { | |
return '<span id="'+e.post_helper_id+'" class="custom-click marker-custom-'+e.post_helper_id+'" style="padding:4px 10px;background-color:#337ab7;color:white;">' + e.price + '€</span>' | |
}, | |
events: { | |
click: function(e) { | |
console.log('click') | |
}, | |
mouseover: function(e) { | |
$('.marker-custom-'+e.item.post_helper_id+'').css('background-color', 'blue') | |
$('.render-'+e.item.post_helper_id+'').css('background-color', 'blue') | |
}, | |
mouseleave: function(e) { | |
$('.marker-custom-'+e.item.post_helper_id+'').css('background-color', '#337ab7') | |
$('.render-'+e.item.post_helper_id+'').css('background-color', 'white') | |
} | |
} | |
} | |
}) | |
); | |
search.start(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment