谷歌地图来一个MVC视图页面 [英] Google map to come an MVC view page

查看:106
本文介绍了谷歌地图来一个MVC视图页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个错误,当我保持api键也没有显示地图..但没有apikey它显示输出



i have an error when i am keeping api key also its not showing map..but without apikey its showing output

<!DOCTYPE html>
<html>
<body>

    <h1>My First Google Map</h1>

    <div id="map" style="width: 100%; height: 500px"></div>

    <script>
        function myMap() {
            var mapCanvas = document.getElementById("map");
            var mapOptions = {
                center: new google.maps.LatLng(51.5, -0.2),
                zoom: 10
            }
            var map = new google.maps.Map(mapCanvas, mapOptions);
        }
    </script>

    <script src="http://maps.googleapis.com/maps/api/js?key=AIzaSyAEPqUnY2L-pAfri4Qk-BwcyUzu5IMTf6w"></script>
</body>
</html>





我是什么尝试过:



没什么。



What I have tried:

Nothing.

推荐答案

根据您发布的代码,你永远不会调用你的 myMap 函数。



将函数名称添加为Google的回调参数地图脚本标记:

Based on the code you've posted, you never call your myMap function.

Add the function name as the "callback" parameter to the Google Maps script tag:
<script src="http://maps.googleapis.com/maps/api/js?key=...&callback=myMap"></script>


这篇关于谷歌地图来一个MVC视图页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆