Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

load from json and clustring #82

Open
GoogleCodeExporter opened this issue Nov 27, 2015 · 2 comments
Open

load from json and clustring #82

GoogleCodeExporter opened this issue Nov 27, 2015 · 2 comments

Comments

@GoogleCodeExporter
Copy link

hi.

im using jquery-ui-map-3.0-rc .

i can load marker from json  , but i can not clustering them.
According to Examples i use this way :

<script type="text/javascript">
$(function() { 
    demo.add(function() {
        $('#map_canvas').gmap({'disableDefaultUI':true, 'callback': function() {

            var self = this;
            $.getJSON( 'json/demo.json', function(data) { 
                $.each( data.markers, function(i, marker) {

                    self.addMarker({ 'position': new google.maps.LatLng(marker.latitude, marker.longitude), 'bounds':true } ).click(function() {
                        self.openInfoWindow({ 'content': marker.content }, this);
                    });
                });
                $(this).gmap('set', 'MarkerClusterer', new MarkerClusterer(map, $(this).gmap('get', 'markers')));
            });
            $(this).gmap('set', 'MarkerClusterer', new MarkerClusterer(map, $(this).gmap('get', 'markers')));
        }}); 
    }).load();
});
</script>

what's problem?
thank you.


Original issue reported on code.google.com by [email protected] on 18 Jan 2014 at 2:43

@GoogleCodeExporter
Copy link
Author

[deleted comment]

@GoogleCodeExporter
Copy link
Author

create the marker cluster after the markers have been added to the map, not 
before. try this :

$(function() { 
        $('#map_canvas').gmap({'center': '37.4419, -122.1419','zoom': 5, 'disableDefaultUI':true}).bind('init', function(evt, map) { 
            $.getJSON('json/demo.json', function(data){
                $.each(data.markers, function(i, marker){
                    $('#map_canvas').gmap('addMarker', {
                        'position': new google.maps.LatLng(marker.latitude, marker.longitude)
                    }).click(function(){
                        $('#map_canvas').gmap('openInfoWindow', {
                            'content': marker.content
                        },this);
                    });
                });
               $('#map_canvas').gmap('set', 'MarkerClusterer', new MarkerClusterer($('#map_canvas').gmap('get', 'map'), $('#map_canvas').gmap('get', 'markers'))); 
            });
        });     
});

Original comment by [email protected] on 22 May 2014 at 6:21

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant