1

Even if I set the options for agm-maps, I see my options for a small amount of time, then they all disappear. I couldn't understand this behaviour. I created a simple project just to demonstrate the problem in Stackblitz, also I'm going to share my code here.

  • code sample

maps.html:

<agm-map [latitude]="lat" [longitude]="lng"
(mapReady)="onMapReady($event)" 
>
  <agm-marker [latitude]="lat" [longitude]="lng"></agm-marker>
</agm-map>

maps.component.ts

  onMapReady(map: any) {
    this.map = map;
    this.map.setOptions({
      mapTypeControl: 'true',
      mapTypeControlOptions: {
        mapTypeIds: ['roadmap', 'hybrid'],
        position: google.maps.ControlPosition.TOP_LEFT,
        style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR
      },
      fullscreenControl: true,
      streetViewControl: true
  });
}
  • Stackblitz

https://stackblitz.com/edit/angular-agm-vvqbao?file=app/app.component.ts

  • Reference

https://github.com/SebastianM/angular-google-maps/blob/f9c23aa5d166ac7408f13891f6bfa2fc16026b19/packages/core/services/google-maps-types.ts#L431-L444


You can see in Stackblitz, my map type controls blink just for a moment in the top left side of the map whenever the maps loads, then disappears for no reason. You probably won't realize in the first try, you can refresh the page while looking at top-left of the map.

Fatih Ersoy
  • 680
  • 1
  • 5
  • 24

1 Answers1

0

#maps.component.ts#

onMapReady(map) {
  map.setOptions({
      mapTypeControl: 'true',
      mapTypeControlOptions: {
        mapTypeIds: ['roadmap', 'hybrid'],
        position: google.maps.ControlPosition.TOP_LEFT,
        style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR
      },
      fullscreenControl: true,
      streetViewControl: true
  });
}
Adrian Mole
  • 49,934
  • 160
  • 51
  • 83
  • 1
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 18 '22 at 20:52