jquery.ui.maps上的多个标记

时间:2013-09-12 14:02:15

标签: jquery google-maps maps

我正在尝试在jquery地图上添加多个标记,但没有取得任何成功:

<script type="text/javascript" src="js/jquery.ui.map.js"></script>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
<script>
//<![CDATA[
    $('#googlemaps').gmap({'center': '44.639391, -63.672101', 'zoom': 10, 'disableDefaultUI':true, 'callback': function() {
        var self = this;
        self.addMarker({'position': this.get('map').getCenter() }).click(function() {
            self.openInfoWindow({ 'content': 'Company Name' }, this);
        });
    }});
//]]>
</script>

1 个答案:

答案 0 :(得分:0)

解决:

$('#googlemaps').gmap({'center': 'your first coords', 'zoom': 10, 'disableDefaultUI':true, 'callback': function() {
        var self = this;
        self.addMarker({'position': this.get('map').getCenter() }).click(function() {
            self.openInfoWindow({ 'content': 'Your 1st Marker Name' }, this);
        });
               self.addMarker({'position': 'your second coords' }).click(function() {
            self.openInfoWindow({ 'content': 'Your 2nd Marker Name' }, this);
        });
    }});