-1

The Google maps javascript api contains a simple example that if I put copy/paste it into a html file and place it on my server works nicely.

However I really want to 'copy/paste' the code into a php file and be able to call some javascript functions to 'add markers' to the map (eventually) - but in order to do that I need help understanding how this html code works - because I do not understand how it is actually displaying something to the page.

https://developers.google.com/maps/documentation/javascript/examples/map-simple

Below is my current php file as you see no php code other than opening and closing the php at this time and then the copy paste of the google maps example - yet divs, and I believe the meta doesn't just 'work' like this because I can't have a head? or body? in joomla article?

What I expect to see when i run this file in joomla would be the same thing I see if I would open up my php file by itself - yet nothing shows up (other then the hello world text)...

    <?php

    ?>

     <head>
        <title>Simple Map</title>
        <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
        <meta charset="utf-8">
        <style>
          html, body, #map-canvas {
            margin: 0;
            padding: 0;
            height: 100%;
          }
        </style>
        <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
        <script>
            var map;
            function initialize() {
                var mapOptions = {
                    zoom: 8,
                    center: new google.maps.LatLng(44.981314, -93.25633),
                    mapTypeId: google.maps.MapTypeId.HYBRID
                };
                map = new google.maps.Map(document.getElementById('map-canvas'),
          mapOptions);
                var myLatlng = new google.maps.LatLng(44.964251, -93.266459);
                var marker = new google.maps.Marker({
                    position: myLatlng,
                    title: "Hello World!"
                });
                marker.setMap(map);
            }

            google.maps.event.addDomListener(window, 'load', initialize);

        </script>
      </head>
      <body>
hello world
        <div id="map-canvas"></div>
      </body>
GregM
  • 3,450
  • 3
  • 33
  • 51
  • So is that an invitation to start a debugging session with you or do you have to a specific programming question after all? – hakre May 02 '13 at 18:31
  • or you could help with the question I asked... let me rephrase it if you chose not to read it the first time... "I took html code placed it in a php file, and call it with jumi inside of a joomla article... nothing shows up... if I directly open the php file it works... I dont understand what the differences are except the joomla already has a header, and body - so what is it i should do to make this work? general guidance would be appreciated not asking anyone to solve all problems – GregM May 02 '13 at 19:10
  • You did not ask any question. You just pasted some code and you make assumptions about it. It's not clear why you think this should work. You write yourself that it is incompatible with Joomla and you didn't outline any steps nor ideas how you can make it compatible with Joomla. The general guidance I am able to give to you is that I do not think it works the way you try it. But that is not much. I'm sorry. – hakre May 02 '13 at 20:10
  • im sorry you don't understand what joomla,jumi,php,and javascript are and the relations they would have when included inside of a joomla feature called an article - don't respond to questions that you don't understand - I still would love help from someone knowledgeable in the area someone that does understand how they interact together and what the pitfalls of having the head/body inside of the article are and where they should be placed - you can leave now thanks for nothing hakre – GregM May 02 '13 at 20:34
  • If you need support for a specific software product, please use the support venues for these products. This is not a Joomla Q&A site, it is a programming FAQ. I'm sorry if you don't understand these relations. Apart from that I tried to be helpful and tried to find out if it's not possible to turn this into a programming question. Apart from that, leaving a comment is different than leaving an answer so please mind that I did not place an answer here but just commented. I'm desperately sorry that I can not be of more help for you. – hakre May 02 '13 at 20:38
  • seeing how its specific to having multiple bodies or multiple headers in an html doc and how to use those that is a programming question sorry its above you to see this – GregM May 02 '13 at 20:56
  • Possible duplicate of: [Multiple in same file](http://stackoverflow.com/questions/2035462/multiple-htmlbody-html-body-in-same-file) - You see how SO works? Specific question, specific answer. – hakre May 02 '13 at 21:02
  • I know that having multiple is an issue... hence the fact that I dont where to place the stuff that is in the above code in my head and body to make it work since I already have one. yet all the code I write in the php doc is only going to be able to be placed in the body code because thats all joomla will let me access inside of an article – GregM May 02 '13 at 21:54

1 Answers1

1

I tried this out and reproduced your issue. If you look at Firebug you can see that the map is retrieved just Joomla is not displaying it for whatever reason.

Duplicate header/body is not the issue (you can load sites with this no problem, although not a good idea as it is not w3c compatible). For proof of concept it is fine.

I don't have a solution but thought it was worth mentioning two options here:

  1. Build your own module. This is really easy. It may seem daunting at first but the tutorial is great. This way you build something clean with no duplicate content :)

  2. Why reinvent the wheel? Use an extension. They can do probably everything you need and more. For example: http://extensions.joomla.org/extensions/maps-a-weather/maps-a-locations/maps/1147

Tom
  • 2,604
  • 10
  • 55
  • 95
  • Next to trying, have you checked that against any technical specification? Did your browser render in fallback or in strict-mode? Have you validated the document? – hakre May 02 '13 at 21:03