FrancescoMussi
FrancescoMussi

Reputation: 21630

JQuery: Gmap with route

I need to work with Gmap plugin using route. i can set up it on a basic map, but the question is how can i include that functionality in a separate js file?

Here is the very simple example i set it up:

http://jsbin.com/iYoKEPa/1

But in dev i need to include it in a load() function on a separate js file. I replicate my dev function on jsbin and try to set the route but was not able to do it:

http://jsbin.com/ejimUf/1

Someone can help me please. Thank you!

Upvotes: 0

Views: 577

Answers (1)

Rob Schmuecker
Rob Schmuecker

Reputation: 8954

You are instantiating two different types of maps between the two documents. In the first one you are making a Gmaps map and in the second one a google.maps map.

Here it works: http://jsbin.com/ejimUf/3/edit

function load(){
  console.log('loaded');
  var point = new google.maps.LatLng(-12.043333, -77.028333);
  var myMapOptions = {
    zoom: 13,   
    center: point,
    div:'#map',
    lat: -12.043333,
    lng: -77.028333

  };



 map = new GMaps(myMapOptions);



  map.drawRoute({
      origin: [-12.044012922866312, -77.02470665341184],
      destination: [-12.090814532191756, -77.02271108990476],
      travelMode: 'driving',
      strokeColor: '#131540',
      strokeOpacity: 0.6,
      strokeWeight: 6
   });

}

Upvotes: 1

Related Questions