Forum Replies Created

Viewing 1 replies (of 1 total)
  • Mohammad Amin

    (@mohammadamindeldari)

    hi my frind, im I’ve got a result

    
    
    function listify_custom_autolocation()
    {
        if (!(is_front_page() || listify_is_job_manager_archive())) {
            return;
        }
        ?>
        <script>
          
                    if (navigator.geolocation) {
                        console.log(navigator.geolocation);
                        navigator.geolocation.getCurrentPosition(function(position) {
                            var pos = {
                                lat: position.coords.latitude,
                                lng: position.coords.longitude
                            };
                            var map = new google.maps.Map(document.getElementById('job_listings-map-canvas'), {
                                zoom: 4,
                                position: pos
                            });
                            console.log(map);
                            var marker = new google.maps.Marker({
                                map: map,
                                position: pos,
                            
                            });
                            console.log(marker);
                            map.setCenter(pos);
                        }, function() {
                            //handle location error (i.e. if user disallowed location access manually)
                        });
                    } else {
                        // Browser doesn't support Geolocation
                    }
        </script>
        <?php
    }
    
    add_action('wp_footer', 'listify_custom_autolocation', 9999);
    
    

    But just show a fraction of a second marker!

Viewing 1 replies (of 1 total)