Google Maps V3 API Reserve Geocode - Unknown property <latlng>

I have markers on my map. Onclick I want to get the address of the tokens using backup geocoding.

Here is my function:

...
    google.maps.event.addListener(marker_obj[ii], 'click', function(){   
        show_marker_information(this);                             
    });  

...

    function show_marker_information(obj){                                        
        //obj = marker                                                            
        if(typeof(infowindow) != 'undefined')                                     
            infowindow.close();                                                   

        var latlng_search = obj.getPosition();                                    

        var geocoder = new google.maps.Geocoder();                                
        geocoder.geocode({                                                        
                'latlng':   latlng_search                                         
            },                                                                    
            function(results, status){                                            
                alert(results.toSource());
            }                                                                     
        );    

When I click on the marker icon, firebug tells me:

Unknown property <latlng>
[Break On This Error] J.toSpan=function(){return new P(this....n(d){return d==k&&c||d instanceof a}} 

Any ideas?

+3
source share
1 answer

I found my error:

 geocoder.geocode({                                                        
            'latlng':   latlng_search                                         
        },                                                                    
        function(results, status){                                            
            alert(results.toSource());
        }                                                                     
    );    

there is no latlng property in the geocoder. it should be "location" instead of "latlng".

+4
source

Source: https://habr.com/ru/post/1780399/


All Articles