Tagged: 

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #512285

    Where would I place script below so I may get my Geocoder map canvas to work? Currently use https://wordpress.org/plugins/insert-php/ for the PHP which doesn’t work for headers nor footer.

    <script type=”text/javascript”>

    function initialize() {

    var address = ‘<?=$loc?>’;
    var geocoder = new google.maps.Geocoder();

    geocoder.geocode( { ‘address’: address}, function(results, status) {
    var location = results[0].geometry.location;
    lat = location.lat();
    lng = location.lng();

    var myLatlng = new google.maps.LatLng(lat,lng);
    var mapOptions = {
    zoom: 19,
    center: myLatlng,
    mapTypeId: google.maps.MapTypeId.HYBRID
    }

    var map = new google.maps.Map(document.getElementById(‘map_canvas’), mapOptions);

    var marker = new google.maps.Marker({
    position: myLatlng,
    map: map,
    title: “<?php echo $_POST[‘fulladdress’] ;?>”
    });

    });
    }
    //var myLatlng = new google.maps.LatLng(lat,lng);

    </script>

    #512317

    Hi WSRJohn!

    You could try adding it to the bottom of the footer.php file. Or add this to the bottom of your functions.php file and insert the script inside it.

    add_action('wp_footer', 'enfold_customization_footer_script');
    function enfold_customization_footer_script(){
    ?>
    insert your script here
    <?php
    }

    Best regards,
    Elliott

    #512434

    Tried that. Broke my theme and had to install back up. Guess not overly sure where in the functions.php to put it. Didn’t think it would matter, but did. Ended up making a widget and inserting it with Widget Shortcode and PHP Text Widget. Thanks though.

    #512602

    Hi,

    Sorry for the problems, glad you found a solution though :-)

    Regards,
    Rikard

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.