Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google maps 我想制作可点击的链接,以便在地图上缩放和显示描述_Google Maps_Google Maps Api 3 - Fatal编程技术网

Google maps 我想制作可点击的链接,以便在地图上缩放和显示描述

Google maps 我想制作可点击的链接,以便在地图上缩放和显示描述,google-maps,google-maps-api-3,Google Maps,Google Maps Api 3,身体 { 字体系列:Arial; 字体大小:15磅; } 变量标记=[ { “标题”:“阿克萨海滩”, “lat”:“19.1759668”, “液化天然气”:“72.7950465999998”, “描述”:“阿克萨海滩是孟买马拉德阿克萨村一个受欢迎的海滩和度假胜地。” }, { “标题”:“巨湖海滩”, “lat”:“19.0883595”, “液化天然气”:“72.82652380000002”, “描述”:“巨湖海滩是孟买最受欢迎的旅游景点之一。” }, { “标题”:“吉尔高姆海滩”,


身体
{
字体系列:Arial;
字体大小:15磅;
}
变量标记=[
{
“标题”:“阿克萨海滩”,
“lat”:“19.1759668”,
“液化天然气”:“72.7950465999998”,
“描述”:“阿克萨海滩是孟买马拉德阿克萨村一个受欢迎的海滩和度假胜地。”
},
{
“标题”:“巨湖海滩”,
“lat”:“19.0883595”,
“液化天然气”:“72.82652380000002”,
“描述”:“巨湖海滩是孟买最受欢迎的旅游景点之一。”
},
{
“标题”:“吉尔高姆海滩”,
“lat”:“18.9542149”,
“液化天然气”:“72.812035299993”,
“描述”:“Girgaum海滩,俗称Chaupati,是孟买最著名的公共海滩之一。”
},
{
“标题”:“Jijamata Udyan”,
“lat”:“18.979006”,
“液化天然气”:“72.83388300000001”,
“描述”:“Jijamata Udyan位于Byculla车站附近,因孟买动物园而闻名。”
},
{
“标题”:“桑杰·甘地国家公园”,
“lat”:“19.2147067”,
“液化天然气”:“72.9106200000004”,
“描述”:“桑杰·甘地国家公园是孟买市北部的一个大型保护区。”
}
];
var myArray=新数组();
var desc=新数组();
window.onload=函数(){
LoadMap();
myFunction(myArray,desc);
}
函数LoadMap(){
变量映射选项={
中心:新建google.maps.LatLng(标记[0].lat,标记[0].lng),
缩放:8,
mapTypeId:google.maps.mapTypeId.ROADMAP
};
var infoWindow=new google.maps.infoWindow();
var latlngbounds=new google.maps.latlngbounds();
var map=new google.maps.map(document.getElementById(“dvMap”)、mapOptions);
对于(var i=0;i对于(i=0;i,这里有一个修改后的示例,演示如何在地图上选择标记:

var g_位置=[
{
“标题”:“阿克萨海滩”,
“lat”:“19.1759668”,
“液化天然气”:“72.7950465999998”,
“描述”:“阿克萨海滩是孟买马拉德阿克萨村一个受欢迎的海滩和度假胜地。”
},
{
“标题”:“巨湖海滩”,
“lat”:“19.0883595”,
“液化天然气”:“72.82652380000002”,
“描述”:“巨湖海滩是孟买最受欢迎的旅游景点之一。”
},
{
“标题”:“吉尔高姆海滩”,
“lat”:“18.9542149”,
“液化天然气”:“72.812035299993”,
“描述”:“Girgaum海滩,俗称Chaupati,是孟买最著名的公共海滩之一。”
},
{
“标题”:“Jijamata Udyan”,
“lat”:“18.979006”,
“液化天然气”:“72.83388300000001”,
“描述”:“Jijamata Udyan位于Byculla车站附近,因孟买动物园而闻名。”
},
{
“标题”:“桑杰·甘地国家公园”,
“lat”:“19.2147067”,
“液化天然气”:“72.9106200000004”,
“描述”:“桑杰·甘地国家公园是孟买市北部的一个大型保护区。”
}
];
var g_信息窗口;
var g_标记=[];
函数loadMap(){
变量映射选项={
中心:新的google.maps.LatLng(地理位置[0].lat,地理位置[0].lng),
缩放:8,
mapTypeId:google.maps.mapTypeId.ROADMAP
};
g_infoWindow=新的google.maps.infoWindow();
var latlngbounds=new google.maps.latlngbounds();
var map=new google.maps.map(document.getElementById(“map”)、mapOptions);
对于(var i=0;i<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <style type="text/css">
        body
        {
            font-family: Arial;
            font-size: 15pt;
        }
    </style>


    <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
    <script type="text/javascript">
        var markers = [
    {
        "title": 'Aksa Beach',
        "lat": '19.1759668',
        "lng": '72.79504659999998',
        "description": 'Aksa Beach is a popular beach and a vacation spot in Aksa village at Malad, Mumbai.'
    },
    {
        "title": 'Juhu Beach',
        "lat": '19.0883595',
        "lng": '72.82652380000002',
        "description": 'Juhu Beach is one of favourite tourist attractions situated in Mumbai.'
    },
    {
        "title": 'Girgaum Beach',
        "lat": '18.9542149',
        "lng": '72.81203529999993',
        "description": 'Girgaum Beach commonly known as just Chaupati is one of the most famous public beaches in Mumbai.'
    },
    {
        "title": 'Jijamata Udyan',
        "lat": '18.979006',
        "lng": '72.83388300000001',
        "description": 'Jijamata Udyan is situated near Byculla station is famous as Mumbai (Bombay) Zoo.'
    },
    {
        "title": 'Sanjay Gandhi National Park',
        "lat": '19.2147067',
        "lng": '72.91062020000004',
        "description": 'Sanjay Gandhi National Park is a large protected area in the northern part of Mumbai city.'
    }
    ];
        var myArray    = new Array();

        var desc    = new Array();

        window.onload = function () {
            LoadMap();
            myFunction(myArray,desc);

        }

        function LoadMap() {
            var mapOptions = {
                center: new google.maps.LatLng(markers[0].lat, markers[0].lng),
                zoom: 8,
                mapTypeId: google.maps.MapTypeId.ROADMAP
            };
            var infoWindow = new google.maps.InfoWindow();
            var latlngbounds = new google.maps.LatLngBounds();
            var map = new google.maps.Map(document.getElementById("dvMap"), mapOptions);

            for (var i = 0; i < markers.length; i++) {

                var data = markers[i]
                var myLatlng = new google.maps.LatLng(data.lat, data.lng);
                var marker = new google.maps.Marker({
                    position: myLatlng,
                    map: map,
                    title: data.title
                });

                myArray[i]=data.title;
                desc[i]=data.description;

                (function (marker, data) {
                    google.maps.event.addListener(marker, "click", function (e) 
                    {

                        infoWindow.setContent("<div style = 'width:60px;min-height:40px'>" + data.description + "</div>");
                        infoWindow.open(map, marker);
                    });

                    marker.addListener('click', function() {
                        map.setZoom(18);
                        map.setCenter(marker.getPosition());
                      });
                })(marker, data);
                latlngbounds.extend(marker.position);    

            }

             var bounds = new google.maps.LatLngBounds();
            map.setCenter(latlngbounds.getCenter());
            map.fitBounds(latlngbounds);

        }



    </script>
    <script>
    function myFunction(myArray,desc) {
        var out = "";
        var i;
        for(i = 0; i<myArray.length; i++) {

            out += '<a href="#" onclick="myClick();">' + 
            myArray[i] + '</a>'+desc[i]+'<br><br><br>';
        }
        document.getElementById("ids").innerHTML = out;
    }



    function myClick()
    {
        alert("hii");
    }
    </script>
    </head>
     <body> 
    <div id="dvMap" style="width: 700px; height: 800px">
    </div>
 <ul id="ids"></ul>

</body>
</html>