Hi,
I want to insert a map with custom markers and then connect those markers to page anchors. Any tips?
Thanks!
Hi,
I want to insert a map with custom markers and then connect those markers to page anchors. Any tips?
Thanks!
Anyone?
Something along the lines of this https://ny.eater.com/maps/best-new-york-restaurants-38-map
Is it possible with webflow?
Hey @moonworks,
Sure I think it is possible, with a few line of JavaScript.
The idea is the following:
window.location.href
within the for loop to trigger the respective url of the markerHere is a codepen I wrote to try my idea out (you’ll need to customize CSS, transition etc… but conceptually, it works.)
Here is my listed ideas translated into JavaScript:
function initMap() {
// Options 👇🏻
const zoom = 12;
// 🦋 define the lattitude and longitude points of each markers
const POINTS = [
{ lat: 59.9362384705039, lng: 30.19232525792222 },
{ lat: 59.941412822085645, lng: 30.263564729357767 }
];
// 🐳 define the URLs id (which are the id of your HTML anchor points)
const URLS = ["#url1", "#url2"];
// definition of the map and its options
const MAP = new google.maps.Map(document.getElementById("map"), {
zoom: zoom,
center: POINTS[0],
});
// 🦊 create a for loop function to populate the arrays above into each markers
for (let i = 0; i < POINTS.length; i++) {
// creation of the marker
const MARKER = new google.maps.Marker({
map: MAP,
position: POINTS[i], // 🦜 inject lat & lng position from the POINTS array
url: URLS[i] // 🦚 inject urls from the URLS array
});
// 🦠 marker url click event listener
google.maps.event.addListener(MARKER, "click", function() {
window.location.href = this.url;
});
}
}
Hope that helps !
This is great. Thanks @anthonysalamin i will give that a go!
Wondering if you ever got this to work
@noslenc the project i was working on changed track a bit so i never tried it out! have you tried it?