问题描述
ngo(在我的情况下)注册那里,他们可以给那里地址,地图类型等(就像嵌入式谷歌地图)地图,以便访问该ngo页面的人可以很容易地找到该ngo,并可以获得该ngo的路线,我不知道如何以及在哪里使用这些谷歌地图,请帮助我,谢谢。我不知道扩展名,但可以轻松创建您的映射方式(在此示例中没有Google Maps键,但如果您的应用使用需要你应该获得一个)
在你的< head>
部分添加这个
'< script src =https://maps.googleapis.com/maps/api/js?sensor=false&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&v=3&"></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:任何扩展实现嵌入谷歌地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!