私は基本的に地図上でユーザーが指定した座標をプリントアウトするhtmlファイルを作っています。送信ボタンをクリックすると、「UncaughtReferenceError:NewMapが定義されていません」というエラーが返されます。外部のJavaScriptとインラインのjavascriptを使用してみましたが、問題を解決できないようです。コードに何が間違っているのか教えてください。HTMLで関数を参照する方法は?
<!DOCTYPE html>
<html>
<head>
<title>Find My Phone</title>
</head>
<body bgcolor="#2196F3">
<p style="font-size:150%; text-align:center">This is the extension for the app FindMyPhone. In this site, you can view the coordinates where your phone was traced on a map</p>
Latitude:
<input type="number" step="any" id="Lat"/> <br>
Longitude:
<input type="number" step="any" id="Lng"/> <br>
<button onclick="NewMap()">Submit</button>
<div id="map" style="height:500px;width:500px; color:#9E9E9E">
</div>
<script>
function NewMap() {
var mapCanvas = document.getElementById("map").value;
var Latitude = document.getElementById("Lat").value;
var Longitude = document.getElementById("Lng").value;
var mapOptions = {
center: document.getElementById("Lat, Lng")
zoom:15
}
var map = new.google.maps.Map (mapCanvas, mapOptions)
}
</script>
</body>
</html>
P.S:このコードを実行すると、マップが正しく出力されますか?それが正しいか間違っているかどうか私にも教えてください。
私はそれを配置する必要がありますか? –
@Martyそれについては確かですか? –
@GerardoFurtado Nah、構文エラー(カンマと余分な '.')がないためです。 – Marty