Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8864421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:14:14+00:00 2026-06-14T16:14:14+00:00

I am struggling to apply a icon zoom level change function to my google

  • 0

I am struggling to apply a icon zoom level change function to my google maps api script.

My current icon size is 48px and the actually graphic is also 48px.

jsfiddle.net/motocomdigital/hQkb3/6

Determined like this…

var image = new google.maps.MarkerImage(
  '<?php bloginfo('template_url'); ?>/images/marker-images/image-48px.png',
  new google.maps.Size(48,48),
  new google.maps.Point(0,0),
  new google.maps.Point(24,48)
);

I don’t suppose it is possible to change these sizes and graphics depending on 3 zoom levels?

For example, when a zoom is at…

Zoom Level 0 > 6 – uses…

  '<?php bloginfo('template_url'); ?>/images/marker-images/image-12px.png',
  new google.maps.Size(12,12),
  new google.maps.Point(0,0),
  new google.maps.Point(6,6)

Zoom Level 6 > 8 – uses…

  '<?php bloginfo('template_url'); ?>/images/marker-images/image-24px.png',
  new google.maps.Size(24,24),
  new google.maps.Point(0,0),
  new google.maps.Point(12,12)

Zoom Level 8+ – uses…

  '<?php bloginfo('template_url'); ?>/images/marker-images/image-48px.png',
  new google.maps.Size(48,48),
  new google.maps.Point(0,0),
  new google.maps.Point(24,24)

This is my original script below…

jQuery(function($){

    var image = new google.maps.MarkerImage(
      '<?php bloginfo('template_url'); ?>/images/marker-images/image.png',
      new google.maps.Size(48,48),
      new google.maps.Point(0,0),
      new google.maps.Point(24,24)
    );

    $('#map_div').gmap3({
        action:'init',
        options: {
            center:[<?php echo $lt;?>,<?php echo $lo;?>],
            zoom: 7,
            scrollwheel: false
        }
    },
    {
        action: 'addMarkers',
        markers: [ <?php echo $lat_long;?> ],
        marker: {
            options: {
                draggable: false,
                icon: image             
            },
            events:{
            mouseover: function(marker, event, data){
                var map = $(this).gmap3('get'),
                    infowindow = $(this).gmap3({ action:'get', name:'infowindow' });
                if (infowindow) {
                    infowindow.open(map, marker);
                    infowindow.setContent(data);
                } else {
                    $(this).gmap3({action:'addinfowindow', anchor:marker, options:{content: data}});
                }
            },
            mouseout: function(){
                var infowindow = $(this).gmap3({ action:'get', name:'infowindow' });
                if (infowindow){
                    infowindow.close();
                }
            }
        }

    }
    });
});

I am really not great with this level of scripting, and any pointers ideas or help would be great thanks.

Josh

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T16:14:15+00:00Added an answer on June 14, 2026 at 4:14 pm

    I added a “zoom_changed” event to your map that changes all marker icons according to the zoom level.

    function UseMarkerIcon(imageObj)
    {
      var markers=$("#map_div").gmap3({action:'get',name:'marker',all:true});
      $.each(markers, function(i,marker)
      {
        marker.setIcon(imageObj);
      });  
    }
    
    jQuery(function($) {    
        var image12px = new google.maps.MarkerImage('http://motocomdigital.co.uk/assets/marker-images/map-marker-12px.png', new google.maps.Size(12, 12), new google.maps.Point(0, 0), new google.maps.Point(6, 6));    
        var image24px = new google.maps.MarkerImage('http://motocomdigital.co.uk/assets/marker-images/map-marker-24px.png', new google.maps.Size(24, 24), new google.maps.Point(0, 0), new google.maps.Point(12, 12));    
        var image48px = new google.maps.MarkerImage('http://motocomdigital.co.uk/assets/marker-images/map-marker-48px.png', new google.maps.Size(48, 48), new google.maps.Point(0, 0), new google.maps.Point(24, 24));
    
        $('#map_div').gmap3({
            action: 'init',
            options: {
                center: [50.799019, -1.132037],
                zoom: 5,
                scrollwheel: false
            },
                  events:{
                          zoom_changed: function(map){
                              var zoomLevel = map.getZoom();
    
                              if (zoomLevel < 6)
                                UseMarkerIcon(image12px);
                              else if (zoomLevel >= 6 && zoomLevel <=8)
                                UseMarkerIcon(image24px);
                              else
                                UseMarkerIcon(image48px);
                          }
                  }
        }, {
            action: 'addMarkers',
            markers: [{
                lat: 50.799019,
                lng: -1.132037,
                data: 'Test One'},
            {
                lat: 50.365162,
                lng: -4.712017,
                data: 'Test Two'},
            {
                lat: 54.518726,
                lng: -5.881054,
                data: 'Test Three'},
            {
                lat: 52.780964,
                lng: -1.211863,
                data: 'Test Four'},
            {
                lat: 51.433998,
                lng: -2.549690,
                data: 'Test Five'}],
            marker: {
                options: {
                    draggable: false,
                    icon: image12px
                },
                events: {
                    mouseover: function(marker, event, data) {
                        var map = $(this).gmap3('get'),
                            infowindow = $(this).gmap3({
                                action: 'get',
                                name: 'infowindow'
                            });
                        if (infowindow) {
                            infowindow.open(map, marker);
                            infowindow.setContent(data);
                        } else {
                            $(this).gmap3({
                                action: 'addinfowindow',
                                anchor: marker,
                                options: {
                                    content: data
                                }
                            });
                        }
                    },
                    mouseout: function() {
                        var infowindow = $(this).gmap3({
                            action: 'get',
                            name: 'infowindow'
                        });
                        if (infowindow) {
                            infowindow.close();
                        }
                    }
    
                }
    
            }
        });
    });
    

    The function UseMarkerIcon(image) iterates through all your markers and sets the image you pass to it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm struggling to apply css-styling to a GWT (Google Web Toolkit) generated html table
I'm currently struggling to get a WebDesignersWall script to function properly on my website.
I am struggling to apply a workaround I found regarding UIWebView accepting tap-events. Source:
Struggling to get any list function to work. I've been fine with _show and
There have been many questions along these lines but I'm struggling to apply them
I've looked through several previous questions but I am struggling to apply the solutions
I'm trying to apply a style to a MapPolyline from the bing maps silverlight
http://www.clker.com/clipart-green-right-double-arrows-set.html I am struggling to apply 9patch to an image like the one above
I am struggling to get this simple PowerShell script to work. I have googled,
I am using the DateTimeField component of Wicket, but I am struggling to apply

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.