Totoro
Totoro

Reputation: 1294

Set the altitude/ height of a google maps marker

I am working with markers and adding them like this:

markerLatLang = new google.maps.LatLng(35.6412142,139.6988337);
marker = new google.maps.Marker({position: markerLatLang, map: map});

When I go in to street view all the markers are at ground level. Is there a way to position a marker at x meters above ground or at a set altitude?

Example of marker on 5th floor of building

Upvotes: 4

Views: 1804

Answers (3)

Joseph
Joseph

Reputation: 1

You can modify the y position/altitude of the marker by adjusting the anchor property of the icon object. The anchor is where the image is placed relative to the marker like translating in CSS.

const marker = new google.maps.Marker({
    position: markerLatLang,
    map: map
    icon: {
        ...
        anchor: new google.maps.Point(0, 250)
    }
});

Upvotes: 0

Atif Saleem
Atif Saleem

Reputation: 146

I have done this using a PNG image having bottom empty space how much you want. I also did not find a proper way to do that but this trick may be helpful to you.

Upvotes: 0

AlexB
AlexB

Reputation: 7416

Unfortunately, as Dr.Molle said, this option doesn't exist in Google Maps API for now.

Upvotes: 3

Related Questions