Yii:任何扩展实现嵌入谷歌地图 [英] Yii: Any extension to implement embedded google map

查看:131
本文介绍了Yii:任何扩展实现嵌入谷歌地图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ngo(在我的情况下)注册那里,他们可以给那里地址,地图类型等(就像嵌入式谷歌地图)地图,以便访问该ngo页面的人可以很容易地找到该ngo,并可以获得该ngo的路线,我不知道如何以及在哪里使用这些谷歌地图,请帮助我,谢谢。

解决方案

我不知道扩展名,但可以轻松创建您的映射方式(在此示例中没有Google Maps键,但如果您的应用使用需要你应该获得一个)



在你的< head> 部分添加这个

 '< script src =https://maps.googleapis.com/maps/api/js?sensor=false&amp;v=3& amp;>< / script>'
< style>
html,body,#map {
height:100%;
margin:0px;
填充:0px
}
< / style>

< body> p>

 < body> 
< div id =map>< / div>
< script>

var yourLat =<?= $ yourLat; ?>
var yourLng =<?= $ yourLng; ?>

函数init(){

var mapOptions = {
zoom:15,
center:new google.maps.LatLng(yourLat,yourLng)
}

var mapElement = document.getElementById('map');

//使用上面定义的元素和选项创建Google地图
var map = new google.maps.Map(mapElement,mapOptions);

var myLatLng = new google.maps.LatLng(yourLat,yourLng);
var yourMarker = new google.maps.Marker({
position:myLatLng,
map:map,
});
}


// Google地图脚本
//当窗口加载完成后,在
下创建我们的谷歌地图google.maps.event.addDomListener (窗口,'load',init);
< / script>

......
< / body>


im a yiibie, and i want to use google maps in my project just like embedded google maps. For example i want that when an ngo(in my case) is registering there ngo they could give there address, type of map etc (just like in embedded google map) on the map so that people visiting that ngo page could easily locate that ngo and can get a route to that ngo, i have no idea of how and where using these google maps, please help me, thank you.

解决方案

I don't know extension but you can easly create you map this way (in this sample there isn't the google maps key but if your app usage require this you should obtain one)

In Your <head> section add this

'<script src="https://maps.googleapis.com/maps/api/js?sensor=false&amp;v=3&amp;"></script>'
    <style>
      html, body, #map {
        height: 100%;
        margin: 0px;
        padding: 0px
      }
    </style>

In <body> add

  <body>
     <div id="map" ></div>
  <script>

    var yourLat = <?= $yourLat; ?>
    var yourLng = <?= $yourLng; ?>

    function init() {

        var mapOptions = {
            zoom: 15,
            center: new google.maps.LatLng(yourLat , yourLng)
        }

        var mapElement = document.getElementById('map');

        // Create the Google Map using out element and options defined above
        var map = new google.maps.Map(mapElement, mapOptions);

        var myLatLng = new google.maps.LatLng(yourLat, yourLng);
        var yourMarker = new google.maps.Marker({
            position: myLatLng,
            map: map,
        });
    }


    // Google Maps Scripts
    // When the window has finished loading create our google map below
    google.maps.event.addDomListener(window, 'load', init);
  </script>

  ......
  </body>

这篇关于Yii:任何扩展实现嵌入谷歌地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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