How to set init function for Google map?

I’m testing init function for jQuery and Google map. How to work Google map
Code is the following:

jQuery(function()
 {
  MapsgoogleID.init();
 }
);

MapsgoogleID = {
init: function() {

  if (jQuery('#mapID1').length) {

   function initialize() {
    var mymap1 = new google.maps.LatLng(IDLAT, IDLng);
    var mapOptions = {
    zoom: 9,
    center: mymap1,
    mapTypeId: google.maps.MapTypeId.ROADMAP
    }
    google.maps.event.addDomListener(window, 'load', initialize);
   }
  }

 }
}
  1. I try to init Google map just when there is actual map inside website.
  2. There seems an error even if I put simple code without addDomListener
    Example:
    Error: TypeError: a is undefined
    maps-api-v3/api/js/

Can we see a demo of your page, in order to check if a problem exists elsewhere on it that’s causing your problem?

I can not add file and even code. How to do it?

Is is testing script to work. Can be uploaded code in file or added Code inside this forum?

Googlemapsample1.zip (711 Bytes)

I have managed now. It is inside ZIP.

You see it has two issues which are missing.

  1. INIT function is not set like I posted due to ID: id=“Googlemap_number1”
    How to do it?
  2. INIT function should be executed only if there is map ID as it will throw an error.

Strange that validator also shows other errors and some none.
Need help.

Hi Paul,
did you check my ZIP file?

Need help.
http://www.sitepoint.com/community/t/how-to-set-init-function-for-google-map/

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.