0

I'm trying to add a GMap to my contact page, I don't have the need for Location / GMap modules. I'm following the tutorial here but following it I have to add everything to the head in my html.tpl file:

<script>
  function initialize() {
    var map_canvas = document.getElementById('map_canvas');
    var map_options = {
      center: new google.maps.LatLng(44.5403, -78.5463),
      zoom: 8,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    }
    var map = new google.maps.Map(map_canvas, map_options)
  }
  google.maps.event.addDomListener(window, 'load', initialize);
</script>

Where else can I place this script? I've tried to add it in a separate JS file and call it through my info file but it doesn't work that way.

1

May be you have miss something.

For Gmap on Drupal site there are many ways to implement.

You can try this approch:

  • Put whole the code in any block with full text format.
  • Place that block in a specific region.
  • Set visiblity of that bock as per your requirment.

Implementation code be like this

enter image description here

2
  • Thank you Rupesh 22, that works fine. But is that the best way to implement it or should I be looking at creating a small custom module to do this? Just want to know best practices. Thanks
    – T Mardi
    Mar 28 '14 at 10:28
  • @TMardi There are not any bad thing to use this approch.
    – Rupesh
    Mar 28 '14 at 16:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.