gpt4 book ai didi

html - 如何在我的网站上正确显示 google maps API?

转载 作者:行者123 更新时间:2023-11-28 17:04:11 26 4
gpt4 key购买 nike

我目前在我的本地主机上工作。我正在尝试在我网站的联系我们表单中显示 google maps API。但是每当我尝试实现它时,都会显示“DeletedApiProjectMapError”。

此外,我怎样才能将联系人表单的名字和姓氏推送到输入字段的左侧而不是居中对齐?如何正确显示 google maps API?我想我已经正确使用了我的验证码。我严格按照 W3Schools 教程在 google maps API 上操作,但没有任何效果。

.topnav a {
color: black;
text-decoration: none;
font-style: bold;
font-size: 20px;
font-family: Cabin;
padding-left: 20px;
padding-right: 20px;
}

.column {
float: left;
width: 25%;
}

/* Clear floats after rows */
.row:after {
content: "";
display: table;
clear: both;
padding: 8px;
}

/* Content */
.content {
background-color: white;
padding: 10px;
}
.topnav{
float: right;
padding-top: 20px;
}

.Who{
padding: 20px;
text-align: center;
font-style: bold;
font-size: 20px;
font-family: Cabin;
}

.Who p{
font-size: 16px;
font-family: Lora;
padding: 20px;
}

h1{
color: black;
font-family: Cabin;
text-align: center;
}
body, html {
height: 100%;
position: relative;
top: 0; right: 0; bottom: 0; left: 0;
margin: 0;
padding: 0;
}

.bg {
/* The image used */
position: relative;
top: 0; right: 0; bottom: 0; left: 0;
background-image: url("house.jpg");
opacity: 0.80;
filter: alpha(opacity=80); /* For IE8 and earlier */

/* Full height */
height: 100%;

/* Center and scale the image nicely */
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
* {
box-sizing: border-box;
}

/* Style inputs */
input[type=text], select, textarea {
width: 100%;
padding: 12px;
border: 1px solid #ccc;
margin-top: 6px;
margin-bottom: 16px;
resize: vertical;
}

input[type=submit] {
background-color: #4CAF50;
color: white;
padding: 12px 20px;
border: none;
cursor: pointer;
}

input[type=submit]:hover {
background-color: #45a049;
}

/* Style the container/contact section */
.con {
border-radius: 5px;
background-color: #f2f2f2;
padding: 10px;
}

/* Create two columns that float next to eachother */
.cols {
float: left;
width: 50%;
margin-top: 6px;
padding: 20px;
}

/* Clear floats after the columns */
.rws:after {
content: "";
display: table;
clear: both;
}
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 traditional//EN">
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=`device-width`, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<link rel="stylesheet" type="text/css" href="style.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
$(function() {
$('a[href*=#]:not([href=#])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html,body').animate({
scrollTop: target.offset().top
}, 1000);
return false;
}
}
});
});
</script>

<link href='https://fonts.googleapis.com/css?family=Cabin:700' rel='stylesheet' type='text/css'>
<link href="https://fonts.googleapis.com/css?family=Lora:400,700,400italic,700italic" rel="stylesheet" type="text/css">
</head>
<body>
<div class = "bg">
<div class="topnav">
<a class="active" href="#Home">Home</a>
<a href="#Who">Who</a>
<a href="#Portfolio">Portfolio</a>
<a href="#Contact">Contact</a>
</div>
</div>
<div class = "Who">
<h1 id= "Who" >Who are we ?</h1>
<p>Cabin is a website theme I created to demonstrate my skills
as a front-end web developer.

This website uses stock photos free of property and commercial rights.
</p>
<h1 id="Portfolio">Portfolio</h1>
<div class="row">
<div class="column">
<div class="content">
<img src="picOne.jpg" alt="" style="width:100%">
<h3>My Work</h3>
<p>Lorem ipsum..</p>
</div>
</div>
<div class="column">
<div class="content">
<img src="picTwo.jpg" alt="" style="width:100%">
<h3>My Work</h3>
<p>Lorem ipsum..</p>
</div>
</div>
<div class="column">
<div class="content">
<img src="picThree.jpg" alt="" style="width:100%">
<h3>My Work</h3>
<p>Lorem ipsum..</p>
</div>
</div>
<div class="column">
<div class="content">
<img src="picFour.jpg" alt="" style="width:100%">
<h3>My Work</h3>
<p>Lorem ipsum..</p>
</div>
</div>
</div>
<div class="row">
<div class="column">
<div class="content">
<img src="picOne.jpg" alt="" style="width:100%">
<h3>My Work</h3>
<p>Lorem ipsum..</p>
</div>
</div>
<div class="column">
<div class="content">
<img src="picTwo.jpg" alt="" style="width:100%">
<h3>My Work</h3>
<p>Lorem ipsum..</p>
</div>
</div>
<div class="column">
<div class="content">
<img src="picThree.jpg" alt="" style="width:100%">
<h3>My Work</h3>
<p>Lorem ipsum..</p>
</div>
</div>
<div class="column">
<div class="content">
<img src="picFour.jpg" alt="" style="width:100%">
<h3>My Work</h3>
<p>Lorem ipsum..</p>
</div>
</div>
</div>
<div>
<h1 id="Contact">Contact Us</h1>

<div class="con">
<div style="text-align:center">
<h3>Contact Form</h3>
</div>
<div class="rws">
<div class="cols">
<div id="map" style="width:100%;height:500px"></div>
</div>
<div class="cols">
<form action="/action_page.php">
<label for="fname">First Name</label>
<input type="text" id="fname" name="firstname" placeholder="Your name..">
<label for="lname">Last Name</label>
<input type="text" id="lname" name="lastname" placeholder="Your last name..">
<label for="country">Country</label>
<select id="country" name="country">
<option value="australia">Australia</option>
<option value="canada">Canada</option>
<option value="usa">USA</option>
</select>
<label for="subject">Subject</label>
<textarea id="subject" name="subject" placeholder="Write something.." style="height:170px"></textarea>
<input type="submit" value="Submit">
</form>
</div>
</div>
</div>

</div>
<div class="footer"> <p id="ft">Website created by Andrew B <br> Date created: 03/04/2016</p></div>
</div>
</body>
<script>
function myMap() {
var myCenter = new google.maps.LatLng(51.508742,-0.120850);
var mapCanvas = document.getElementById("map");
var mapOptions = {center: myCenter, zoom: 12};
var map = new google.maps.Map(mapCanvas, mapOptions);
var marker = new google.maps.Marker({position:myCenter});
marker.setMap(map);
}

</script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBtU_Z1n3cfwKbDlRN_incLUZVPHof0DJA&callback=myMap"></script>

</html>

最佳答案

How to bring the form left to the maps ?

只需将 maps div 放在 form div 旁边即可。

Regarding DeletedApiProjectMapError and Loading the map in localhost

您必须在 Google 控制台中启用 API。 More info in this SO answer

更新内容:

.topnav a {
color: black;
text-decoration: none;
font-style: bold;
font-size: 20px;
font-family: Cabin;
padding-left: 20px;
padding-right: 20px;

}

.column {
float: left;
width: 25%;
}

/* Clear floats after rows */
.row:after {
content: "";
display: table;
clear: both;
padding: 8px;
}

/* Content */
.content {
background-color: white;
padding: 10px;
}
.topnav{
float: right;
padding-top: 20px;

}

.Who{
padding: 20px;
text-align: center;
font-style: bold;
font-size: 16px;
font-family: Cabin;
}

.Who p{
font-size: 16px;
font-family: Lora;
padding: 20px;
}

h1{
color: black;
font-family: Cabin;
text-align: center;
}
body, html {
height: 100%;
position: relative;
top: 0; right: 0; bottom: 0; left: 0;
margin: 0;
padding: 0;
}

.bg {
/* The image used */
position: relative;
top: 0; right: 0; bottom: 0; left: 0;
background-image: url("house.jpg");
opacity: 0.80;
filter: alpha(opacity=80); /* For IE8 and earlier */

/* Full height */
height: 100%;

/* Center and scale the image nicely */
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
* {
box-sizing: border-box;
}

input[type=submit] {
background-color: #4CAF50;
color: white;
padding: 12px 20px;
border: none;
cursor: pointer;
}

input[type=submit]:hover {
background-color: #45a049;
}

/* Style the container/contact section */
.con {
border-radius: 5px;
background-color: #f2f2f2;
padding: 10px;
}

/* Create two columns that float next to eachother */
.cols {
float: left;
width: 50%;
margin-top: 6px;
padding: 10px;
}

/* Clear floats after the columns */
.rws:after {
content: "";
display: table;
clear: both;
}

form {
margin: 0 auto;
}

form div + div {
margin-top: 1em;
}

label {
display: inline-block;
width: 90px;
text-align: right;
}
input, textarea,select {
width: 100px;
}
input:focus, textarea:focus {
border-color: #000;
}
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 traditional//EN">
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=`device-width`, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<link rel="stylesheet" type="text/css" href="style.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
$(function() {
$('a[href*=#]:not([href=#])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html,body').animate({
scrollTop: target.offset().top
}, 1000);
return false;
}
}
});
});
</script>

<link href='https://fonts.googleapis.com/css?family=Cabin:700' rel='stylesheet' type='text/css'>
<link href="https://fonts.googleapis.com/css?family=Lora:400,700,400italic,700italic" rel="stylesheet" type="text/css">
</head>
<body>
<div class = "bg">
<div class="topnav">
<a class="active" href="#Home">Home</a>
<a href="#Who">Who</a>
<a href="#Portfolio">Portfolio</a>
<a href="#Contact">Contact</a>
</div>
</div>
<div class = "Who">
<h1 id= "Who" >Who are we ?</h1>
<p>Cabin is a website theme I created to demonstrate my skills
as a front-end web developer.

This website uses stock photos free of property and commercial rights.
</p>
<h1 id="Portfolio">Portfolio</h1>
<div class="row">
<div class="column">
<div class="content">
<img src="picOne.jpg" alt="" style="width:100%">
<h3>My Work</h3>
<p>Lorem ipsum..</p>
</div>
</div>
<div class="column">
<div class="content">
<img src="picTwo.jpg" alt="" style="width:100%">
<h3>My Work</h3>
<p>Lorem ipsum..</p>
</div>
</div>
<div class="column">
<div class="content">
<img src="picThree.jpg" alt="" style="width:100%">
<h3>My Work</h3>
<p>Lorem ipsum..</p>
</div>
</div>
<div class="column">
<div class="content">
<img src="picFour.jpg" alt="" style="width:100%">
<h3>My Work</h3>
<p>Lorem ipsum..</p>
</div>
</div>
</div>
<div class="row">
<div class="column">
<div class="content">
<img src="picOne.jpg" alt="" style="width:100%">
<h3>My Work</h3>
<p>Lorem ipsum..</p>
</div>
</div>
<div class="column">
<div class="content">
<img src="picTwo.jpg" alt="" style="width:100%">
<h3>My Work</h3>
<p>Lorem ipsum..</p>
</div>
</div>
<div class="column">
<div class="content">
<img src="picThree.jpg" alt="" style="width:100%">
<h3>My Work</h3>
<p>Lorem ipsum..</p>
</div>
</div>
<div class="column">
<div class="content">
<img src="picFour.jpg" alt="" style="width:100%">
<h3>My Work</h3>
<p>Lorem ipsum..</p>
</div>
</div>
</div>
<div>
<h1 id="Contact">Contact Us</h1>

<div class="con">
<div style="text-align:center">
<h3>Contact Form</h3>
</div>
<div class="rws">
<div class="cols">
<div id="map" style="width:100%;height:500px"></div>
</div>
<div class="cols">
<form action="/action_page.php">
<div>
<label for="fname">First Name</label>
<input type="text" id="fname" name="firstname" placeholder="Your name..">
</div>
<div>
<label for="lname">Last Name</label>
<input type="text" id="lname" name="lastname" placeholder="Your last name..">
</div>
<div>
<label for="country">Country</label>
<select id="country" name="country">
<option value="australia">Australia</option>
<option value="canada">Canada</option>
<option value="usa">USA</option>
</select>
</div>
<div>
<label for="subject">Subject</label>
<textarea id="subject" name="subject" placeholder="Write something.." style="height:170px"></textarea>
</div>
<div class="button">
<input type="submit" value="Submit">
</div>
</form>
</div>
</div>
</div>

</div>
<div class="footer"> <p id="ft">Website created by Andrew B <br> Date created: 03/04/2016</p></div>
</div>
</body>
<script>
function myMap() {
var myCenter = new google.maps.LatLng(51.508742,-0.120850);
var mapCanvas = document.getElementById("map");
var mapOptions = {center: myCenter, zoom: 12};
var map = new google.maps.Map(mapCanvas, mapOptions);
var marker = new google.maps.Marker({position:myCenter});
marker.setMap(map);
}

</script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBtU_Z1n3cfwKbDlRN_incLUZVPHof0DJA&callback=myMap"></script>

</html>

关于html - 如何在我的网站上正确显示 google maps API?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50704500/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com