开发者

cluster google maps marker, when they share the same pixel

开发者 https://www.devze.com 2023-02-06 01:45 出处:网络
How do i find if more than one mark开发者_运维问答er are being shown on the same location?The way i did it is:I store the markers on an array and upon marker creation i check if a marker on the locati

How do i find if more than one mark开发者_运维问答er are being shown on the same location?


The way i did it is:I store the markers on an array and upon marker creation i check if a marker on the location i try to add a new marker is already exists.If true i use this idea to place the marker in a near point.Hope it helps


omg ... i remember that was not fun ... but the solution was like that:

you have all your positions and titles/content in an array. while walking through that array you add the position to an other array. if the current position is in that array, you don't add the marker but add it's bubble the content of the current marker.

in the bubble i had two buttons to switch through the content items.

the switch was not easy to implement as generic as possible (for me) but here you have the code:

wrapper.find('.bubble_next').bind('click',  function(event){
                var active = $(this).parent().find('.active');
                var next = active.next('.list_item');
                if(next.length == 0) {
                    var all = $(this).parent().find('.list_item');
                    next = $(all[0]);
                }

                active.hide();
                next.fadeIn(200);
                next.addClass('active');
                active.removeClass('active');

                var items = $(this).parent().find('.list_item');
                for(var i=0; i<items.length; i++) if($(items[i]).hasClass('active')) $(this).parent().find('.bubble_index').text((i+1));

            });

where bubble index is some index for the marker, and wrapper a layer in the bubble which holds the content item-layers. i think the rest of the css-classes are speaking for themselfes.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号