1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

Get Google Map Marker Position on Screen

Discussão em 'Angular' iniciado por VSO, Setembro 1, 2025.

  1. VSO

    VSO Guest

    Is there a way to get the bounding rectangle (screen position) of Google Map API markers? I am using an Angular 2 wrapper, so I don't construct the markers like you would normally with the API (mostly irrelevant here though).

    Or are they on an internal canvas with no way to pull position like you would with an HTML element?

    I have tried something like this, but getBoundingRectangle() comes back with zero values:

    var googleMapContent = document.getElementsByClassName("sebm-google-map-content")[0];

    var markerList = googleMapContent.getElementsByTagName("sebm-google-map-marker");

    if( markerList.length > 0 ) {
    for (var i = 0; i < markerList.length; i++ ){
    var marker = markerList;
    var markerLabel = marker.getAttribute("ng-reflect-label");
    var boundingRectangle = marker.getBoundingClientRect();
    }
    }


    P.S. I have access to map center lat/lng + zoom and marker lat/lng, so I can "math" this, but that's pretty dirty.

    Continue reading...

Compartilhe esta Página