googlemapsapi和PHP
我有这个密码googlemapsapi和PHP,php,google-maps,google-maps-api-3,Php,Google Maps,Google Maps Api 3,我有这个密码 现在,我想把地图放在一个网站上,让人们通过地理编码服务报告一些特定的事件。我想问一下,我如何才能在一个表中获得该事件的地址/坐标,并将所有用户报告收集到一个数据库中。您需要设置某种类型的操作侦听器(最好是一个侦听用户单击地图的侦听器)。然后,只需对生成的lat/lng进行地理编码,并将收到的数据存储在表中 用户单击地图上的一个点 单击事件获取用户单击的lat/lng Lat/lng使用Ajax为文本地址进行地理编码 Lat/lng和文本地址并排存储在数据库表中 您需要设置某种类型
现在,我想把地图放在一个网站上,让人们通过地理编码服务报告一些特定的事件。我想问一下,我如何才能在一个表中获得该事件的地址/坐标,并将所有用户报告收集到一个数据库中。您需要设置某种类型的操作侦听器(最好是一个侦听用户单击地图的侦听器)。然后,只需对生成的lat/lng进行地理编码,并将收到的数据存储在表中
您需要设置某种类型的操作侦听器(最好是侦听用户单击地图的侦听器)。然后,只需对生成的lat/lng进行地理编码,并将收到的数据存储在表中
关于将GoogleMapsAPIv3与PHP/MySQL接口,在
这个看起来像是回答了你的问题 关于将Google Maps API v3与PHP/MySQL接口,在
这个看起来像是回答了你的问题 请参阅下面的代码并尝试 我使用php静态数组,您可以连接您的数据库,并根据您的要求创建数组。请参见下面的数组
<?php $item = array('jaipur, rajasthan,india', 'udaipur, rajasthan,india'); ?>
下面是我的代码,请看一看
<html>
<head>
<script src="http://maps.google.com/maps?file=api&v=2&key=AIzaSyDwFjOazEAe1MI7nHV6vUwkWytOp8LH2Zk" type="text/javascript"></script>
</head>
<body onload="initialize();">
<?php $item = array('jaipur, rajasthan,india', 'udaipur, rajasthan,india'); ?>
<script>
var map = null;
var geocoder = null;
function initialize() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map_canvas"));
var addresses = ["<?php echo implode ('","', $item); ?>"]
var geocoder = new GClientGeocoder();
//var addresses = ["A II Z, Ibn Battuta Mall, Sheikh Zayed Road, 5th Interchange, Jebel Ali Village, Dubai","A. Testoni,Dubai Festival City Mall, Ground Floor, Dubai", "Abdulla Hussain Khunji, The Dubai Mall,Downtown, Abu Dhabi"];
var curIndex = 0;
function showAddress() {
var _cur = addresses[curIndex];
geocoder.getLatLng(
_cur,
function(point) {
if (!point) {
//alert(_cur + " not found");
//map.setCenter(new GLatLng(0, 0), 6);
//map.setUIToDefault();
} else {
//console.log(_cur+":"+point);
//alert(_cur);
var cafeIcon = new GIcon(G_DEFAULT_ICON);
// Set up our GMarkerOptions object
markerOptions = { icon:cafeIcon };
map.setCenter(point, 6);
var marker = new GMarker(point, markerOptions);
map.addOverlay(marker);
var sales = new Array();
sales = _cur.split("|");
//Add click event on push pin to open info window on click of the icon
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml("<p class='para1bold' style=\"font-weight: bold;\">Address <br /><span class='para1' style='font-weight:normal;'>" + sales[1] + "</span></p>");
});
//Provides map,satellite,hybrid and terrain views in the map along with zoom control
map.setUIToDefault();
}
//do next after done
curIndex++;
if(curIndex<addresses.length)
showAddress();
}
);
}
showAddress();
}
}
</script>
<div id="map_canvas" style="width:100%; height:750px;"></div>
</body>
</html>
var-map=null;
var-geocoder=null;
函数初始化(){
if(GBrowserIsCompatible()){
map=newgmap2(document.getElementById(“map_canvas”);
var addresses=[“请参阅下面的代码并尝试
我使用的是php静态数组,您可以连接数据库并根据需要创建数组。请参见下面的数组
<?php $item = array('jaipur, rajasthan,india', 'udaipur, rajasthan,india'); ?>
下面是我的代码,请看一看
<html>
<head>
<script src="http://maps.google.com/maps?file=api&v=2&key=AIzaSyDwFjOazEAe1MI7nHV6vUwkWytOp8LH2Zk" type="text/javascript"></script>
</head>
<body onload="initialize();">
<?php $item = array('jaipur, rajasthan,india', 'udaipur, rajasthan,india'); ?>
<script>
var map = null;
var geocoder = null;
function initialize() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map_canvas"));
var addresses = ["<?php echo implode ('","', $item); ?>"]
var geocoder = new GClientGeocoder();
//var addresses = ["A II Z, Ibn Battuta Mall, Sheikh Zayed Road, 5th Interchange, Jebel Ali Village, Dubai","A. Testoni,Dubai Festival City Mall, Ground Floor, Dubai", "Abdulla Hussain Khunji, The Dubai Mall,Downtown, Abu Dhabi"];
var curIndex = 0;
function showAddress() {
var _cur = addresses[curIndex];
geocoder.getLatLng(
_cur,
function(point) {
if (!point) {
//alert(_cur + " not found");
//map.setCenter(new GLatLng(0, 0), 6);
//map.setUIToDefault();
} else {
//console.log(_cur+":"+point);
//alert(_cur);
var cafeIcon = new GIcon(G_DEFAULT_ICON);
// Set up our GMarkerOptions object
markerOptions = { icon:cafeIcon };
map.setCenter(point, 6);
var marker = new GMarker(point, markerOptions);
map.addOverlay(marker);
var sales = new Array();
sales = _cur.split("|");
//Add click event on push pin to open info window on click of the icon
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml("<p class='para1bold' style=\"font-weight: bold;\">Address <br /><span class='para1' style='font-weight:normal;'>" + sales[1] + "</span></p>");
});
//Provides map,satellite,hybrid and terrain views in the map along with zoom control
map.setUIToDefault();
}
//do next after done
curIndex++;
if(curIndex<addresses.length)
showAddress();
}
);
}
showAddress();
}
}
</script>
<div id="map_canvas" style="width:100%; height:750px;"></div>
</body>
</html>
var-map=null;
var-geocoder=null;
函数初始化(){
if(GBrowserIsCompatible()){
map=newgmap2(document.getElementById(“map_canvas”);
变量地址=[”