Hello! Why can't I get the directions? I'm a beginner and I have no clue where the problem is.
When I open it in the live browser I can see the map but no option to choose routes. -
<!DOCTYPE html>
-
<html>
-
<head>
-
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
-
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
-
<style type="text/css">
-
html { height: 100% }
-
body { height: 100%; margin: 0px; padding: 0px }
-
#map_canvas { height: 100%; width: 70%; float: left }
-
#directionsPanel { height: 100%; width: 30%; float: right }
-
</style>
-
<title>Google Maps JavaScript API v3 Example: Map Simple</title>
-
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
-
<script type="text/javascript">
-
-
var map;
-
-
function initialize() {
-
-
var mapContainer = document.getElementById("map_canvas");
-
-
var myLatlng = new google.maps.LatLng(61.96059634727177, 9.485308435018732);
-
var myOptions = {
-
zoom: 5,
-
center: myLatlng,
-
mapTypeId: google.maps.MapTypeId.ROADMAP
-
}
-
-
map = new google.maps.Map(mapContainer, myOptions);
-
}
-
</script>
-
</head>
-
<body onload="initialize()">
-
<div id="map_canvas"></div>
-
<div id="directionsPanel"></div>
-
<div id="floating-panel">
-
<b>Start</b>
-
<select id="start:">
-
<option value="Oslo, Norway">Oslo</option>
-
<option value="Drammen, Norway">Drammen</option>
-
<option value="Jevnaker, Norway">Jevnaker</option>
-
</select>
-
<b>End</b>
-
<select id="End:">
-
<option value="Oslo, Norway">Oslo</option>
-
<option value="Drammen, Norway">Drammen</option>
-
<option value="Jevnaker, Norway">Jevnaker</option>
-
-
-
</select>
-
</div>
-
<div id="map"></div>
-
<script>
-
function initMap() {
-
var directionsService = new google.maps.directionsService();
-
var directionsDisplay = new google.maps.DirectionsRenderer();
-
var map = new google.maps.Map(document.getElementById("Map"), {
-
zoom: 7,
-
-
});
-
directionsDisplay.setMap(map);
-
directionsDisplay.setPanel(document.getElementById("directionsPanel"));
-
-
var onChangeHandler = function() {
-
calculateAndDisplayRoute(directionsService, directionsDisplay);
-
-
};
-
document.getElementById('Start').addEventListener('change', onChangeHandler);
-
document.getElementById('End').addEventListener('change', onChangeHandler);
-
-
}
-
-
function calcRoute() {
-
var start = document.getElementById("start").value;
-
var end = document.getElementById("emd").value;
-
var request = {
-
origin:start,
-
destination:end,
-
travelMode: google.maps.DirectionsTravelMode.DRIVING
-
};
-
directionsService.route(request, function(response, status) {
-
if (status == google.maps.DirectionsStatus.OK) {
-
directionsDisplay.setDirections(response);
-
}else {
-
alert("Directions failed:" + status);
-
-
}
-
-
});
-
}
-
-
-
</script>
-
-
<script async defer>
-
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCFIr-BLZtLsDVpj7FPXF0NaCnmgoNUmVE"
-
</script>
-
</body>
-
-
</html>
-
2 4352
Hello! Why can't I get the directions? I'm a beginner and I have no clue where the problem is.
I see errors in the code. Syntax error in lines 95, 96. Typo in line 75. Use the browser developer tools to debug the code. Also, make sure the API key is valid.
When I open it in the live browser I can see the map but no option to choose routes.
Did you try scrolling down?
accidently commented sorry~!
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Mario |
last post by:
Hello everybody,
I am looking for a good script to work a searchprogram for Google .... How
can tel me? Not with a logo from google
THnx
--
-------"""-------
---()---
°?----(_)-----?°
|...
|
by: Daniele |
last post by:
Hi there is a way to put in a struct of vectors all the possibles routes
in a graph from s to d?
Hi thought Dijkstra but I don't know how can i do.
Thanks
Dax
|
by: mitymouse |
last post by:
I am fairly familiar with scripting dos commands and that's about it. I remember some syntax and whatnot from a few programming classes I've taken but I don't remember any of the modules or functions...
|
by: underground |
last post by:
I have a problem that I've spent countless hours on and I'm more than certain this is a obviuos issue to an expert but I am still learning. I have a paging script that I have modified to display a...
|
by: shapper |
last post by:
Hi,
I was checking the new ASP.NET MVC Preview 4 features and I found the
following:
var dataTokens = new RouteValueDictionary();
dataTokens.Add("namespaces", new HashSet<string>(
new string...
|
by: ursular |
last post by:
Hi all,
I'm new to JavaScript and Google Maps API. I got some problems but I cannot find out the reason. Hope someone can help me.
What I tried to do:
I'm trying to develop an application in...
|
by: Nicodemas |
last post by:
I have a web site on a web hosting company's Windows server. The same server also handles my "@nicodemas.com" email and DNS. I have changed my MX records away from their service and use Google...
|
by: spt1956 |
last post by:
/system/service.php
My Google analytic is showing a good percentage of visits from random sites that i am not familiar with.
the referral is PRweb.
If the are the referral source why are all these...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM).
In this month's session, the creator of the excellent VBE...
|
by: MeoLessi9 |
last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: Aftab Ahmad |
last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below.
Dim IE As Object
Set IE =...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: marcoviolo |
last post by:
Dear all,
I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
| |