WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How to configure google maps in wordpress? (4 posts)

  1. Guta
    Member
    Posted 6 years ago #

    Hello.
    I have make one key account in google maps. I DONT want to use PLUGINS to interact googlemaps with wordpress because i must do some advenced topics in the future.
    In Google says that i must pust this code, but it is html with javascript and wordpress is all php files:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <title>Google Maps JavaScript API Example</title>
    <script src="http://maps.google.com/maps?file=api&v=2&key=MI_KEY"
    type="text/javascript"></script>
    <script type="text/javascript">

    //<![CDATA[

    function load() {
    if (GBrowserIsCompatible()) {
    var map = new GMap2(document.getElementById("map"));
    map.setCenter(new GLatLng(37.4419, -122.1419), 13);
    }
    }

    //]]>
    </script>
    </head>
    <body onload="load()" onunload="GUnload()">
    <div id="map" style="width: 500px; height: 300px"></div>
    </body>
    </html>

    I have create one new page (no post) where i want to put the google map, so where or how i put this code so it appears only in that page?

    Thank you for your help.

    PD: I repeat i dont want plugin soluttions

  2. Samuel Wood (Otto)
    Tech Ninja
    Posted 6 years ago #

    What they gave you is a complete html page. You can make your own Page Template and make that code do, more or less, whatever you want it to do.

  3. Guta
    Member
    Posted 6 years ago #

    Ok i understand, but it seems that i can't mix html code with php code as wordpress do.
    For example. I have created one new Page template copying contact.php to maps.php wich looks like this:

    <?php
    /*
    Template Name: Localizator
    */
    $cp_question = "6+3 = ?";
    $cp_answer = "9";
    ?>
    <?php get_header(); ?>
            <div id="content">
            <div id="content-main">
    
            <?php if (have_posts()) : ?>
                            <?php while (have_posts()) : the_post(); ?>
                                    <div class="post">
                                    <?php
                                            //validate email adress
                                            function is_valid_email($email)
                                            {
                                                    return (eregi ("^([a-z0-9_]|\\-|\\.)+@(([a-z0-9_]|\\-)+\\.)+[a-z]{2,4}$"\
    , $email));

    etc, etc

    But if i put the html code anywhere it does not work. It says error in line x
    So. where must i put my html googlemaps code?
    How can i put this code in contact.php for example?

    Thank you very much and excuses my newbie questions. I am sys admin and Webmasters world is very dificult...

  4. Guta
    Member
    Posted 6 years ago #

    Ok I have it!
    Thank you,thenk you very much.

    I just copy another template and modified it like:

    <?php
    /*
    Template Name: Localizator
    */
    ?>
    <?php get_header();?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
        <title>Google Maps JavaScript API Example</title>

    etc, etc

    I mark it as solved
    Best regards

Topic Closed

This topic has been closed to new replies.

About this Topic