warrenfitzhenry
warrenfitzhenry

Reputation: 2299

'Maptype' for Googlemaps Api

I am trying to change the maptype from the default to satellite. I have tried this (I'm using Flask framework)

 {{googlemap("map_name", lat=-33.92508, lng= 18.84614, zoom=17, maptype= 'satellite', markers=[(-33.92508, 18.84614)])}}

but the map is still coming out in the default road map. any ideas?

Upvotes: 0

Views: 294

Answers (1)

duncan
duncan

Reputation: 31920

Looking at the code of the Flask plugin I assume you're using, this expects the maptype property to be one of the google.maps.MapTypeId constants

mapTypeId: google.maps.MapTypeId.{{gmap.maptype}},

Which are the following, all upper-case:

  • HYBRID
  • ROADMAP
  • SATELLITE
  • TERRAIN

https://developers.google.com/maps/documentation/javascript/3.exp/reference#MapTypeId

The google.maps.MapTypeId.SATELLITE constant is equal to the string 'satellite'. So if you were creating the map yourself instead of using this plugin, you could use either of these when initialising the google.maps.Map object:

mapTypeId: google.maps.MapTypeId.SATELLITE  
mapTypeId: 'satellite'

But because the Flask plugin just concatenates the string you specify to the end of google.maps.MapTypeId, you need to use the upper-case constant.

So change your code to:

{{googlemap("map_name", lat=-33.92508, lng= 18.84614, zoom=17, maptype='SATELLITE', markers=[(-33.92508, 18.84614)])}}

Upvotes: 1

Related Questions