Jump to content

Google Search


MOGSY

Recommended Posts

   Hi

 

I am trying to do an address search, I am using the following JS code, however, I get the error "can't read property "places" undefined.

 

I would much appreciate your help.

 

 UniSession.AddJS('var gm = googleMap; '+

                       'if (typeof gm == "object") '+
                       '{ '+
 
                       '  var imagecar = "car.png"; '+
                       '  var searchBox = new gm.maps.places.SearchBox("219 Leicester Road, Marlfield, LE67 9RF"); '+
                       '  var places = searchBox.getPlaces(); '+
                       '  if (places.length != 0) '+
                       '  { '+
                       '    places.forEach '+
                       '    ( '+
                       '      function(place) '+
                       '      { '+
                       '        markers.push '+
                       '        ( '+
                       '          new google.maps.Marker '+
                       '          ( '+
                       '            { '+
                       '              map: gm, '+
                       '              icon: imagecar, '+
                       '              title: place.name, '+
                       '              position: place.geometry.location '+
                       '            } '+
                       '          ) '+
                       '        ) '+
                       '      } '+
                       '    ); '+
                       '  } '+
 
                       '} '
                       );

error_message.html

Link to comment
Share on other sites

×
×
  • Create New...