Onclick in Marker in the Maps API

Asked

Viewed 367 times

0

Hello, how do I run onclick on a map marketer?

My code is this:

    var marker = new google.maps.Marker({
    position: myLatLng,
    map: map,
    icon: andando,
    shape: shape,
    title: beach[0],
    html: beach[5],
    zIndex: beach[3]
});

on onclick I need you to open a popup and pass a value to the popup, the value I’m getting on the beach[5].

1 answer

2


Implying that you already know how to create popups. Add the event like this and use the variable marker.html:

marker.addListener('click', function() {
    /* Aqui você utiliza a variável marker.html */
});

See the documentation of Googlemaps;

  • var Marker = new google.maps.Marker({ position: myLatLng, map: map, icon: walking, Shape: Shape, title: beach[0], html: beach[5], zIndex: beach[3] }); google.maps.Event.addListener(Marker, 'click', Function() ' popupMarker(Marker.html); });

  • couldn’t...

  • Couldn’t make the event work or the popup? Do you already have the code to show the popup or some window? If you have another part of code, please post.

  • Marker.addListener('click', Function(){ window.open('test.php'); });

  • I got this, but the value of beach[5] could not pass the test.php

  • Then your question is to pass the variable to the file teste.php. That?

  • 1

    I got it, thanks.

Show 2 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.