$(document).ready(initialize);
var directionsDisplay;
var directionsService;
var map;
function initialize() {
$("#send").click(newDirection);
directionsDisplay = new google.maps.DirectionsRenderer();
var myLatlng = new google.maps.LatLng(10.485997, -66.822002);
var myLatlng2 = new google.maps.LatLng(10.491357, -66.920965);
var myOptions = {
//center: new google.maps.LatLng(10.491357, -66.920965),
center: myLatlng,
zoom: 14,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
//map = new google.maps.Map($('#map_canvas')[0], myOptions);
directionsDisplay.setMap(map);
placeMarker(myLatlng, map);
placeMarker(myLatlng2, map);
calcRoute("caracas, ve", "maracaibo, ve");
/*var marker = new google.maps.Marker({
position: map.getCenter(),
map: map,
title: 'Click to zoom'
});
google.maps.event.addListener(map, 'center_changed', function () {
// 3 seconds after the center of the map has changed, pan back to the
// marker.
window.setTimeout(function () {
map.panTo(marker.getPosition());
}, 3000);
});
google.maps.event.addListener(marker, 'click', function () {
map.setZoom(8);
map.setCenter(marker.getPosition());
});*/
google.maps.event.addListener(map, 'click', function (event) {
placeMarker(event.latLng, map);
});
}
function placeMarker(location, map) {
var marker = new google.maps.Marker({
position: location,
map: map,
draggable: true
});
//marker.setAnimation(google.maps.Animation.BOUNCE);
//map.setCenter(location);
}
function calcRoute(a, b) {
directionsService = new google.maps.DirectionsService();
var request = {
origin: a,
destination: b,
travelMode: google.maps.TravelMode.DRIVING
};
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.