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

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

问题描述

我是一个 yiibie,我想在我的项目中使用谷歌地图,就像嵌入谷歌地图一样.例如,我希望当 ngo(在我的情况下) 在那里注册非政府组织时,他们可以在地图上提供地址、地图类型等(就像在嵌入式谷歌地图中一样),以便人们访问非政府组织页面可以轻松找到该非政府组织并可以获得前往该非政府组织的路线,我不知道如何以及在何处使用这些谷歌地图,请帮助我,谢谢.

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.

推荐答案

我不知道扩展名,但您可以通过这种方式轻松创建地图(在此示例中没有 google maps 键,但如果您的应用程序使用需要这个你应该得到一个)

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>

中添加

  <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天全站免登陆