change zoom level of marker

New home Forums Pro Add-on General queries change zoom level of marker

Tagged: ,

Viewing 8 posts - 16 through 23 (of 23 total)
  • Author
    Posts
  • #57639
    verewhittome
    Participant
    This reply has been marked as private.
    #57643
    Dylan
    Moderator

    Hi Vere,

    Only a pleasure, happy to help wherever possible.

    I believe the following code snippet should function as intended:

    jQuery(document.body).on('infowindowopen.wpgmza', function(e){
    	var tmarkid = e.target.mapObject.id;
        var tmapid = e.target.mapObject.map_id;
    
        WPGMZA.getMapByID(tmapid).setZoom(13);
    
        var newC = WPGMZA.getMapByID(tmapid).getMarkerByID(tmarkid).getPosition();
    	WPGMZA.getMapByID(tmapid).setCenter(newC);
    });

    This can be added directly to the custom JavaScript section found under Maps -> Settings -> Advanced.

    Adding the code here means it will not be removed by future updates.

    I hope this helps?

    • This reply was modified 4 months ago by Dylan.
    #57666
    verewhittome
    Participant

    Sorry Dylan – it seems like I can’t see your private reply. Am I doing something wrong?

    Thanks!
    Vere

    #57668
    Dylan
    Moderator

    Hi Vere,

    My sincerest apologies, it was not supposed to be flagged as a private reply.

    This was an oversight on my part, please refresh the thread and the reply should be public. 🙂

    #57688
    verewhittome
    Participant

    That’s perfect! Thanks so much Dylan 🙂

    #57689
    Dylan
    Moderator

    Hi Vere,

    Only a pleasure, glad to hear that helped!

    Please do let me know if you need anything else in the future.

    🙂

    #57960
    figaro
    Member

    So I previously got my markers to zoom and centre on click, and then zoom back out to the maps initial zoom level and centre point. This was largely thanks to this thread, the help of the community and the help of the support team here.

    Now I’m using the latest version of the plugins for a new project, but the code I have no longer works to achieve the above.

    The code I was using is:

    
    //zoom on marker click
    
    if(typeof WPGMZA !== 'undefined' && typeof WPGMZA.maps !== 'undefined'){
    	for(var mapid in WPGMZA.maps){
    		var modMap = WPGMZA.maps[mapid];
    		for(var i in modMap.markers){
    			var mark = modMap.markers[i];
    			mark.on('click', function(){
    				modMap.panTo(this.position);
    				modMap.setZoom(6);
    			});
            }
        }
    }
    
    //reset to initial zoom/centre on infowindow close
    
    $(document.body).on("infowindowclose.wpgmza", function(event) {
      var map = WPGMZA.maps[0];
    	map.setZoom(3);
      map.setCenter({lat: 31.327621, lng: 9.750692999999956});
    	
    });
    

    (please note, I’ve had to leave out the ‘function’ opening and closing lines as the forum wouldn’t let me post them)

    Plugin versions I’m using on the new project are:

    WPGMAPS: v8.0.19
    Pro add-on: v5.80

    Any help greatly appreciated!

    • This reply was modified 3 months, 3 weeks ago by figaro.
    #57973
    figaro
    Member

    Please ignore the above request. I’ve realised that support had sent me the wrong version of Pro. I should be using v7. Once I updated to v7 the code that I’d previously been using works again.

Viewing 8 posts - 16 through 23 (of 23 total)
  • You must be logged in to reply to this topic.