0

I manage to copy/write/edit this code, but it doesn't seem to work, not even alert(); is executed, it does exactly nothing.

<?php // include "from_db.php"; ?>

<!DOCTYPE html>
<html>
    <head>
        <script src="http://maps.googleapis.com/maps/api/js"></script>
        <script src="http://code.jquery.com/jquery-1.11.2.min.js"></script>
        <link rel="stylesheet" href="styles.css" media="screen" />

        <script>
            function initialize() {
                var mapProp = {
                    center: new google.maps.LatLng(51.509, -0.121),
                    zoom: 5,
                    mapTypeId:google.maps.MapTypeId.ROADMAP
                };
                var map = new google.maps.Map(document.getElementById("googleMap"), mapProp);
            }
            google.maps.event.addDomListener(window, "load", initialize);
        </script>
    </head>
    <body>
        <div id="googleMap"> </div>
        <input type="text" id="input" placeholder="Placename..." />
        <script>
            $("#input").keyup(function (e) {
                if (e.keyCode == 13) {
                    alert("Linux deyum!");
                    var address = document.getElementById("address").value;
                    geocoder.geocode( { 'address': address}, function(results, status) {
                        if (status == google.maps.GeocoderStatus.OK) {
                            map.setCenter(results[0].geometry.location);
                            var marker = new google.maps.Marker({
                                map: map,
                                position: results[0].geometry.location
                            });
                            alert(marker);
                        }
                        else {
                            alert("Geocode was not successful for the following reason: " + status);
                        }
                    });
                }
            }
        </script>
    </body>
</html>
3
Contributors
3
Replies
12
Views
2 Years
Discussion Span
Last Post by pixelsoul
1

Thanks for the info. I'll be sure not to use it.

...or were you asking a question?

0

>.>, that guy though.

Yes, it is a question. I thought the sentence was clear enough to throw that itself at the reader.

1

Not sure if this is the only reason, but you're not closing your jQuery function properly.

$("#input").keyup(function (e) {
    if (e.keyCode == 13) {
        alert("Linux deyum!");
        var address = document.getElementById("address").value;
        geocoder.geocode( { 'address': address}, function(results, status) {
            if (status == google.maps.GeocoderStatus.OK) {
                map.setCenter(results[0].geometry.location);
                var marker = new google.maps.Marker({
                    map: map,
                    position: results[0].geometry.location
                });
                alert(marker);
            }
            else {
                alert("Geocode was not successful for the following reason: " + status);
            }
        });
    }
});
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.