js-markerwithlabel icon indicating copy to clipboard operation
js-markerwithlabel copied to clipboard

Maps: InfoWindows not appearing

Open gigo6000 opened this issue 2 years ago • 16 comments

Environment details

  1. Api Maps
  2. Ubuntu/React
  3. MarkerWithLabel Version ^2.0.14

Steps to reproduce

  1. Go to the basic example: https://googlemaps.github.io/js-markerwithlabel/examples/basic.html
  2. Click on any marker
  3. No InfoWindow shows up

Code example

function initMap() {
        var latLng = new google.maps.LatLng(49.47805, -123.84716);
        var homeLatLng = new google.maps.LatLng(49.47805, -123.84716);

        var map = new google.maps.Map(document.getElementById("map_canvas"), {
          zoom: 12,
          center: latLng,
          mapTypeId: google.maps.MapTypeId.ROADMAP,
        });

        var marker1 = new markerWithLabel.MarkerWithLabel({
          position: homeLatLng,
          draggable: false,
          clickable: false,
          map: map,
          labelContent: "$425K",
          labelAnchor: new google.maps.Point(-21, 3),
          labelClass: "labels", // the CSS class for the label
          labelStyle: { opacity: 0.75 },
        });

        var marker2 = new markerWithLabel.MarkerWithLabel({
          position: new google.maps.LatLng(49.475, -123.84),
          draggable: true,
          map: map,
          labelContent: "$395K",
          labelAnchor: new google.maps.Point(-21, 3),
          labelClass: "labels", // the CSS class for the label
          labelStyle: { opacity: 1.0 },
        });

        var iw1 = new google.maps.InfoWindow({
          content: "Home For Sale",
        });
        var iw2 = new google.maps.InfoWindow({
          content: "Another Home For Sale",
        });
        google.maps.event.addListener(marker1, "click", function (e) {
          iw1.open(map, this);
        });
        google.maps.event.addListener(marker2, "click", function (e) {
          iw2.open(map, this);
        });
      }


gigo6000 avatar Oct 24 '22 14:10 gigo6000

same here

nzamps avatar Oct 25 '22 22:10 nzamps

Forcing &v=3.49 on the google maps api fixes it

nzamps avatar Oct 25 '22 23:10 nzamps

@nzamps thanks! that worked 👍🏽 🎉

gigo6000 avatar Oct 27 '22 15:10 gigo6000

same here! I wasted so much time debugging this issue 😩 Hope they fix this ASAP

vivek-kandhvar avatar Nov 01 '22 17:11 vivek-kandhvar

Forcing &v=3.49 on the google maps api fixes it

How and where do we do that?

vivek-kandhvar avatar Nov 01 '22 17:11 vivek-kandhvar

depends how you are specifiying the google api. We have a script tag like:

But note: this is only a temporary solution as 3.49 will be EOL next year:

https://developers.google.com/maps/documentation/javascript/versions

nzamps avatar Nov 01 '22 19:11 nzamps

Got it. We use https://www.npmjs.com/package/@googlemaps/react-wrapper, which in turn loads the api for us. Can hard code for now. Hope google fixes this soon.

vivek-kandhvar avatar Nov 02 '22 03:11 vivek-kandhvar

@vivek-kandhvar we use a different react package but it also uses the @googlemaps/js-api-loader to load the Google Maps Api, according to the docs of react-wrapper all options accepted by @googlemaps/js-api-loader are also accepted as props to the wrapper component so you should be able to do something like this:

  <Wrapper apiKey={"YOUR_API_KEY"} render={render} version='3.49'>
    <MyMapComponent />
  </Wrapper>

gigo6000 avatar Nov 02 '22 09:11 gigo6000

Precisely, we have until May 2023 to fix this

image

guix77 avatar Jan 09 '23 11:01 guix77

This appears to be working again now. I had to add a new param "callback" to get it to work or it errors with:

"Loading the Google Maps JavaScript API without a callback is not supported: https://developers.google.com/maps/documentation/javascript/url-params#required_parameters js:258"

e.g. &callback=initMap

		<script>
			function initMap() {
			};
		</script>

Can anyone else verify?

nzamps avatar Feb 07 '23 00:02 nzamps

Actually, not working. The Info windows popup in the wrong location.

nzamps avatar Feb 07 '23 01:02 nzamps

Any solution for it till now ???

vijay-t13 avatar Mar 01 '23 04:03 vijay-t13

I'm also very interested in a solution ;)

hakksor avatar Mar 06 '23 14:03 hakksor

infoWindow.setPosition(marker.getPosition()); can help you

Nimesh028 avatar Apr 28 '23 06:04 Nimesh028

I spent a day until I found this error, please fix it. Thank you. The workaround infoWindow.setPosition(marker.getPosition()); helps, but the infowindow has not the right position. moving it up by changing lng value is not that simple since it depends on the map zoom level`?

HolgerLang avatar Feb 21 '24 11:02 HolgerLang

No news on this issue? Is this library still being maintained?

fernandomantoan avatar Mar 15 '24 19:03 fernandomantoan