Sandra Larsson
Sandra Larsson

Reputation: 31

Error when using google maps api directions

I get the following error trying to declare

var directionsService = new google.maps.DirectionsService();

The error in my console

 TypeError: Result of expression 'google.maps.DirectionsService' [undefined] is not a       constructor.

Any ideas?

Upvotes: 1

Views: 3419

Answers (1)

Ruslan
Ruslan

Reputation: 10147

You must add script reference to the <head> of your page:

<script type="text/javascript" 
    src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>

Upvotes: 3

Related Questions