Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I did a small test for the google map API. But it doesn't show in the WordPress. Basically, I copy and paste one sample code in the file. Codes address: http://stackoverflow.com/questions/11637755/google-map-api-in-wordpress-without-a-plugin In the header.php:

    <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>

In the template of my plugin:

    <script type="text/javascript">
        function initialize() {

            var leeds = new google.maps.LatLng(53.80583, -1.548903);

            var firstLatlng = new google.maps.LatLng(53.80583, -1.548903);              

            var firstOptions = {
                zoom: 16,
                center: firstLatlng,
                mapTypeId: google.maps.MapTypeId.ROADMAP 
            };

            var map = new google.maps.Map(document.getElementById("map_leeds"), firstOptions);

            firstmarker = new google.maps.Marker({
                map:map,
                draggable:false,
                animation: google.maps.Animation.DROP,
                title: 'Your Client',
                position: leeds
            });

            var contentString1 = '<p>The Address<br />Of your client<br />in<br />here</p>';


            var infowindow1 = new google.maps.InfoWindow({
                content: contentString1
            });

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

        }
        </script>


        <div class="map">

            <div id="map_leeds" style="width: 600px; height: 600px"></div>  

        </div>

But it doesn't work. Could someone point out which part I did wrong?

Thank you for helping!

share|improve this question
2  
where do you call initialize()? – Milo Mar 20 at 15:27
I am very new in the Wordpress. I deleted body tag and inserted initialize(), but it turns out echo a bunch of string. Yes, I do need extra <body> tag and initialize()! Now it works:). Thank you for helping. – Pluto Mar 20 at 15:41

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.