在Google地图上添加多个兴趣点

时间:2013-07-31 15:34:26

标签: google-maps-api-3

我有一个很好的脚本,可以让我在Google地图上获得1点兴趣,但我需要更多POI(+ - 15)

有人可以帮助我调整此脚本以轻松启用多个位置吗? 我坦率地看不出我要做什么(作为此代码中的新手) 我愿意切换到其他代码,但我特别喜欢已添加到此代码中的样式。

GOOGLE.map = function(){
if($('.map').length > 0)
{

    $('.map').each(function(i,e){

        $map = $(e);
        $map_id = $map.attr('id');
        $map_lat = $map.attr('data-mapLat');
        $map_lon = $map.attr('data-mapLon');
        $map_zoom = parseInt($map.attr('data-mapZoom'));
        $map_title = $map.attr('data-mapTitle');



        var latlng = new google.maps.LatLng($map_lat, $map_lon);            
        var options = { 
            scrollwheel: false,
            draggable: false, 
            zoomControl: false,
            disableDoubleClickZoom: false,
            disableDefaultUI: true,
            zoom: $map_zoom,
            center: latlng,
            mapTypeId: google.maps.MapTypeId.ROADMAP
        };

        var styles = [ 
                        {
                          stylers: [
                            { hue: "#78dd3e" },
                            { saturation: -100 }
                          ]
                        }, {
                            featureType: "road",
                            elementType: "geometry",
                            stylers: [
                                { lightness: 100 },
                                { visibility: "simplified" }
                          ]
                        }, {
                            featureType: "road",
                            elementType: "labels",
                            stylers: [
                                { visibility: "off" }
                          ]
                        }
                    ];

        var styledMap = new google.maps.StyledMapType(styles,{name: "Styled Map"});

        var map = new google.maps.Map(document.getElementById($map_id), options);

        var image = '_include/img/marker.png';
        var marker = new google.maps.Marker({
            position: latlng,
            map: map,
            title: $map_title,
            icon: image
        });

        map.mapTypes.set('map_style', styledMap);
        map.setMapTypeId('map_style');

        var contentString = '<p><strong>Light Falls</strong><br></p>';

        var infowindow = new google.maps.InfoWindow({
            content: contentString
        });

        google.maps.event.addListener(marker, 'click', function() {
            infowindow.open(map,marker);
        });

    });
}   
}

谢谢!

0 个答案:

没有答案