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 4358
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: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |