Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using variable name different than markers fails #418

Closed
Juantxor opened this issue Aug 27, 2022 · 3 comments
Closed

Using variable name different than markers fails #418

Juantxor opened this issue Aug 27, 2022 · 3 comments
Assignees
Labels
triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@Juantxor
Copy link

Juantxor commented Aug 27, 2022

This code works only if variable "hello" is named "markers".

<html>
  <head>
    <title>Marker Clustering</title>
<script src="https://unpkg.com/@googlemaps/markerclusterer/dist/index.min.js"></script>
    <link rel="stylesheet" type="text/css" href="css/main.css" />
    <script  src="tt.js"></script>
  </head>
  <body>
    <div id="map"></div>
    <script
    src="https://maps.googleapis.com/maps/api/js?key=????&callback=initMap&v=weekly"
    defer
  ></script>
  </body>
</html>
function initMap() {
    const map = new google.maps.Map(document.getElementById("map"), {
      zoom: 3,
      center: { lat: -28.024, lng: 140.887 },
    });
      const marker = new google.maps.Marker({
        img_id:344,
        position: new google.maps.LatLng( -31.56391,147.154312 )
      });
      const marker1 = new google.maps.Marker({
        img_id:344,
       position: { lat: -33.718234, lng: 150.363181 }
      });
      const marker2 = new google.maps.Marker({
        img_id:344,
        position:{ lat: -33.727111, lng: 150.371124 }
      });
      const marker3 = new google.maps.Marker({
        img_id:344,
        position: { lat: -33.848588, lng: 151.209834 }
      });
     const hello = [marker,marker1,marker2,marker3]
     new  markerClusterer.MarkerClusterer({ hello, map });
  }
  window.initMap = initMap;
@Juantxor Juantxor added triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Aug 27, 2022
@Juantxor Juantxor reopened this Aug 28, 2022
@Bar-Maz
Copy link

Bar-Maz commented Aug 29, 2022

If you want to do it this way, just write it like this:

new  markerClusterer.MarkerClusterer({ markers: hello, map });

It's not a bug, it's the javascript syntax

@amuramoto
Copy link
Member

Thanks for providing an answer to this @Bar-Maz !

@wangela
Copy link
Member

wangela commented Aug 9, 2023

@Juantxor plesae make sure to delete the API key above from your account and replace it in any projects that use it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

4 participants