Home > Back-end >  How do I change Oceania to Austrailia on the google maps?
How do I change Oceania to Austrailia on the google maps?

Time:01-07

I am using google Maps API with Angular, and when I zoom out all the way I see this:

Image here

this is supposed to say "Australia" instead of Oceania. Is there a way we can change that ?

CodePudding user response:

Well first you want to set the Map Center to Australia

So something like: const center = { lat: -25.363, lng: 131.044 };

Also you can set the bounds restrictions. Then set the Zoom level so sreen fits the entire country.

So JS code will look something like this:

const center = { lat: -25.363, lng: 131.044 };
const zoom = 4;

this.map = new google.maps.Map(this.mapDiv.nativeElement, {
    center: center,
    zoom: zoom,

    minZoom: zoom - 3,
    maxZoom: zoom   3,

    disableDefaultUI: true,
    restriction: {
      latLngBounds: {
        north: -10,
        south: -40,
        east: 160,
        west: 100,
      },
    },
});

You will just have to play around with the zoom, center, restriction values to fit your needs.

Documentation for this is here:

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

  •  Tags:  
  • Related