更新纬度&;使用Javascript的经度值
我正在使用rails 3.2.12中的google地图,我需要通过infoWindow更新位置创建值的纬度和经度值 如果我单击地图上的任何标记,infowindow将打开,其中包含位置名称和两个按钮(“更新”和“删除”),单击“更新”,当前infowindow将关闭并打开文本字段中显示的其他InfoW窗口纬度和经度值 请在下面找到我的代码 单击更新按钮,下面的函数应调用更新纬度&;使用Javascript的经度值,javascript,ruby-on-rails-3,google-maps-markers,Javascript,Ruby On Rails 3,Google Maps Markers,我正在使用rails 3.2.12中的google地图,我需要通过infoWindow更新位置创建值的纬度和经度值 如果我单击地图上的任何标记,infowindow将打开,其中包含位置名称和两个按钮(“更新”和“删除”),单击“更新”,当前infowindow将关闭并打开文本字段中显示的其他InfoW窗口纬度和经度值 请在下面找到我的代码 单击更新按钮,下面的函数应调用 function getlocation(){ currentprojectid = $('#cur
function getlocation(){
currentprojectid = $('#currentprojectid').val();
sid = $('#sessionid').val();
uid = $('#userid').val()
var locdata = {
userid: ,
sessionid: sid,
command: 'locationupdate',
projectid: currentprojectid
};
markersArray.push(marker);
currentmarker = marker;
var infowindow = new google.maps.InfoWindow();
google.maps.event.addListener(marker, 'click', function(event){
infowindow.close()
infowindow.setContent("<p>LocatioName: <input id="country" type="text" value='+ address +'></p>\
<p>Longitude: <input id="lat" type="text" value='+ lattitude +'> </p>\
<p>Lattitude: <input id="long" type="text" value='+ longitude +'> </p>\
<p><input type="button" value="Save" onclick="saveLocation(currentprojectid)"/
<input type="button" value="Remove" onclick="removeMarker()"/></p>");
infowindow.open(map, marker);
});
currentmarker = marker;
var marker = new google.maps.Marker({
map: Gmaps.map.map,
position: new google.maps.LatLng(lattitude, longitude),
draggable: true
});
函数getlocation(){
currentprojectid=$('#currentprojectid').val();
sid=$('#sessionid').val();
uid=$('#userid').val()
变量locdata={
用户ID:,
会话ID:sid,
命令:“locationupdate”,
projectid:currentprojectid
};
markersArray.push(marker);
currentmarker=标记;
var infowindow=new google.maps.infowindow();
google.maps.event.addListener(标记,'click',函数(事件){
infowindow.close()
infowindow.setContent(“位置名称:\
经度:\
格子:\
如果要从数据库中提取数据,请按标记的id删除标记 尝试此代码..如果此代码对您有帮助:
<head>
<script src="js/jquery.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDMM9AqbeqIGxanHcZc9Ce3C9rRSRz6qvI&v=3.exp&libraries=places&sensor=false&"></script>
<script>
var map;
var marker;
var center = new google.maps.LatLng(21.0000,78.0000);
function initialize(){
var mapProp = {
center:center,
zoom:5,
mapTypeId:google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("googleMap")
,mapProp);
var content = "<input type='button' id='click' value='add marker' />";
var infowindow = new google.maps.InfoWindow();
var marker = new google.maps.Marker({
position:center
});
marker.setMap(map);
google.maps.event.addListener(marker, 'click', function() {
infowindow.setContent(content);
infowindow.open(map, marker);
// currentPopup = null;
});
}
</script>
</head>
<body onload="initialize()">
<div id="googleMap" style="height:500px; width:550px"></div>
<script>
$("body").on("click","#click",function(){
var mycenter = new google.maps.LatLng(24.0000,78.0000);
var marker = new google.maps.Marker({
position:mycenter
});
marker.setMap(map);
var infowindow = new google.maps.InfoWindow();
infowindow.setContent("am new");
infowindow.open(map,marker);
});
</script>
</body>
var映射;
var标记;
var center=new google.maps.LatLng(21.0000,78.0000);
函数初始化(){
var mapProp={
中心:中心,,
缩放:5,
mapTypeId:google.maps.mapTypeId.ROADMAP
};
map=新的google.maps.map(document.getElementById(“谷歌地图”)
,mapProp);
var-content=“”;
var infowindow=new google.maps.infowindow();
var marker=new google.maps.marker({
位置:中
});
marker.setMap(map);
google.maps.event.addListener(标记'click',函数(){
infowindow.setContent(content);
信息窗口。打开(地图、标记);
//currentPopup=null;
});
}
$(“body”)。在(“click”上,“#click”,function(){
var mycenter=new google.maps.LatLng(24.0000,78.0000);
var marker=new google.maps.marker({
位置:迈森特
});
marker.setMap(map);
var infowindow=new google.maps.infowindow();
infowindow.setContent(“am new”);
信息窗口。打开(地图、标记);
});