jquery - Trigger Google map click event with zoom javascript - Stack Overflow

Is there any way to add an click event with zoom? I am able to perform both individually, but when I us

Is there any way to add an click event with zoom? I am able to perform both individually, but when I use zoom together with a click event it is not working properly.

google.maps.event.trigger(gmarkers[count], "click");
map.setZoom(parseInt(k));

Please refer this jsfiddle: /
An example found here: .html

Is there any way to add an click event with zoom? I am able to perform both individually, but when I use zoom together with a click event it is not working properly.

google.maps.event.trigger(gmarkers[count], "click");
map.setZoom(parseInt(k));

Please refer this jsfiddle: http://jsfiddle/Uw9Qy/
An example found here: http://www.geocodezip./v3_MW_example_map3_clustered.html

Share Improve this question edited Jul 6, 2019 at 12:38 Brian Tompsett - 汤莱恩 5,89372 gold badges61 silver badges133 bronze badges asked Dec 18, 2013 at 9:43 Prajila V PPrajila V P 5,3373 gold badges27 silver badges37 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 3

In your fiddle, you have defined the myClick function (which gets triggered as you click one of the text links), but that function doesn't contain any zoom code.

Try this:

Change the onclick on your <b> tags, add a zoomlevel to it

<b onclick="myclick(0, 11)">Berlin</b>-<b onclick="myclick(1, 8)">Paris</b>-<b onclick="myclick(2, 9)">Rome</b>

Then, add a paramter to your myclick function so you can zoom in:

    this.myclick = function (i, zoomlevel) {
        google.maps.event.trigger(gmarkers[i], 'click');
        map.setZoom(zoomlevel);
    };
function createMarker() {

            var marker = new google.maps.Marker({
                position: z,
                map: map,
                title: title,
                html: contentstring
            });

            google.maps.event.addListener(marker, 'click', function () {
                map.setCenter(marker.getPosition());
                map.setZoom(10);
                infowindow.setContent(this.html);
                infowindow.open(map, marker);

            });

            //google.maps.event.addListener(marker,'click',function(){
            //window.location.href = marker.url;
            //});   

            gmarkers[ids] = marker;

        };

Specify your desired zoom level in setZoom() :)

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745354658a4624044.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信