Показать сообщение отдельно
  #1 (permalink)  
Старый 13.09.2012, 10:08
Интересующийся
Отправить личное сообщение для Rayzor Посмотреть профиль Найти все сообщения от Rayzor
 
Регистрация: 27.08.2012
Сообщений: 22

помогите преобразовать javascript в jquery
Здравствуйте, очень нужна помощь.
Есть javascript функции (внутри <script></script>работали, после переноса их в плагин jquery - перестали):

geocoder.geocode( { 'address': options.address }, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
marker.setPosition(results[0].geometry.location);
}
});


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


помогите их преобразовать в jquery.
после переноса кода из обычного скрипта javascript в плагин jquery эти функции не отрабатывают. большая просьба помочь.

вот полный код плагина:
(function($){
    $.fn.addressMap = function(options) {

    var opts = $.extend({
        zoom: 18,
        mapTypeId: google.maps.MapTypeId.ROADMAP
        }, options);

    var geocoder = new google.maps.Geocoder();

    var map = new google.maps.Map($(this), opts);

        geocoder.geocode( { 'address': options.address }, function(results, status) {
            if (status == google.maps.GeocoderStatus.OK) {
                map.setCenter(results[0].geometry.location);
                marker.setPosition(results[0].geometry.location);
            }
        });

        var infowindow = new google.maps.InfoWindow({
            content: options.address
        });
        var marker = new google.maps.Marker({
            map: map
        });

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

//return this
    }
})(jQuery);
Ответить с цитированием