Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
Locked
0

Changing default Zoom level on Google Maps in web apps maps module

Mentor ,
Jul 12, 2012 Jul 12, 2012

Sometimes you may want to change the zoom level on the Google map rendered by the Web Apps map module. The default zoom level is set to 10, but Google provides levels from 1 -16.

To render a map you need to insert a map module into a page, which looks like this:

{module_webappsmap,4682,a,,ABQIAAAAFpzxY6IeWCvvzZBuZgZEFRScORB2vu23Xe0GmXrkmbsnDwR-VhR9W-Y43KrBb8dE8sVMwbyjiM8sMw,600,600,-1}

To change the zoom level all you have to do is add the following code below the maps module on the page:

<script>

CMS.Maps.map.setZoom(14);

</script>

Where 14 is a zoom level.

TOPICS
Documentation
3.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Nov 15, 2012 Nov 15, 2012

Great
Is it also possible to add the default long. and lad.? For some reason I don't understand, my starting position is in the Atlantic Ocean, and my items are located in Denmark so it's a bit astray...
Please see for yourself at http://smykkekaeden01.businesscatalyst.com/butikker-1

Thanks
/Shanne

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Nov 16, 2012 Nov 16, 2012

I found the solution at https://developers.google.com/maps/documentation/javascript/v2/introduction#Map_DOM_Elements

<script>
CMS.Maps.map.setCenter(new GLatLng(56.13330691237569, 10.755615234375), 7);

</script>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 19, 2013 Aug 19, 2013
<script>
CMS.Maps.map.setZoom(14);
</script>

This JS code doesn't change anything with map zoom level at all. The map just continues to zoom to the maximum level of 16 which is useless as you can't even see one street at max zoom.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 17, 2013 Sep 17, 2013

I agree with greetingsfromhelvetica2. The CMS.Maps.map.setZoom(14); doesn't seem to have any effect. Anything else we can do while using the webappsmap module? Zoom level should be added as a parameter to the tag.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 22, 2013 Sep 22, 2013

I have the same issue as per greetingsfromhelvetica2 and gina3five

If I look at the source of the rendered page, the suggested script sits outside the google map script - does that matter?

<div><script src="//maps.googleapis.com/maps/api/js?v=3&sensor=false&key=AIzaSyDsCR3uJk0Glt1bz2_NuFOLyuG3aORgYsU" type="text/javascript"></script><script src="/CatalystScripts/gmaps.js" type="text/javascript"></script><div id="webapp_map_1451" style="height: 400px; width: 400px;"></div><script type="text/javascript">

var webapp_map_1451_gmap2 = CMS.Maps.Initialize({id:"webapp_map_1451",width:400,points:[[0,0,1,"Allium","\n","11 Teed Street,Auckland,,,NZ"]]});</script>

<br />

<script>CMS.Maps.map.setZoom(10);

</script>

</div>

Does anyone have a solution to this problem?

Cheers

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 19, 2014 Mar 19, 2014
LATEST

Just in case anyone else comes across this, you may need to set a timeout to make sure the map is finished initialising before setting the zoom level.

<script>setTimeout(function() { CMS.Maps.map.setZoom(14) }, 800);</script>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines