Search code examples
google-mapsinitializationjquery-gmap3

init gmap3 using geocode


I am new to gmap3, is it possible to init the gmap3 using a place address? I know generally it is done with latitude and longitude. I have done markers with this this location name using this example. I have already gone through this example too, but no luck. And also i need to zoom the places on selection, i use auto complete for this purpose.

My code is given below

 $('#test').gmap3(
     { action:'init',
         options:{
             address: "kerala,india"
         }
     }

 );

Solution

  • First use getLatLng() to retrieve the location, when successfull set the center:

       $('#test1').gmap3(
        { action : 'getLatLng',
          address:'kerala,india',
          callback : function(result){
            if (result){
              $(this).gmap3({action: 'setCenter', args:[ result[0].geometry.location ]},
                            {action: 'setZoom', args:[ 12]});
          } else {
          alert('not found !');
          }}});