GoogleMapV3:使用AJAX+ASP/PHP加载标记,并在Ruquest或事件上重新加载
嗨,我搜索了很多东西,找到了很多内容,但实际上没有找到我需要的东西 我可以加载所有标记,但无法刷新或重新加载。请帮助我,以下是代码:GoogleMapV3:使用AJAX+ASP/PHP加载标记,并在Ruquest或事件上重新加载,ajax,google-maps-api-3,Ajax,Google Maps Api 3,嗨,我搜索了很多东西,找到了很多内容,但实际上没有找到我需要的东西 我可以加载所有标记,但无法刷新或重新加载。请帮助我,以下是代码: $(document).ready(function() { var myLatLng = new google.maps.LatLng(24.86802, 67.06416); MYMAP.init('#map', myLatLng, 11); $(document).ready(function(e){ MYMAP.
$(document).ready(function() {
var myLatLng = new google.maps.LatLng(24.86802, 67.06416);
MYMAP.init('#map', myLatLng, 11);
$(document).ready(function(e){
MYMAP.placeMarkers('testasp.asp');
});
});
var curr_infw;
var MYMAP = {
map: null,
bounds: null,
infowindow:null
}
MYMAP.init = function(selector, latLng, zoom) {
var myOptions = {
zoom:zoom,
center: latLng,
mapTypeId: google.maps.MapTypeId.HYBRID
}
this.map = new google.maps.Map($(selector)[0], myOptions);
this.bounds = new google.maps.LatLngBounds();
}
MYMAP.placeMarkers = function(filename) {
$.get(filename, function(xml){
$(xml).find("marker").each(function(){
var name = $(this).find('name').text();
var address = $(this).find('address').text();
// create a new LatLng point for the marker
var lat = $(this).find('lat').text();
var lng = $(this).find('lng').text();
var point = new google.maps.LatLng(parseFloat(lat),parseFloat(lng));
var infowindow = null;
// extend the bounds to include the new point
MYMAP.bounds.extend(point);
var marker = new google.maps.Marker({
position: point,
map: MYMAP.map,
clickable: true,
icon: 'truck_green.png'
});
//var infowindow = null;
infoWindow = new google.maps.InfoWindow();
var html='<strong>'+name+'</strong.><br />'+address;
google.maps.event.addListener(marker, 'mouseover', function() {
infoWindow.setContent(html);
infoWindow.open(MYMAP.map, marker);
});
MYMAP.map.fitBounds(MYMAP.bounds);
});
});
}
如果有人帮我,我想刷新它使用点击事件或设置超时功能虽然
向您致意,并期待不久在这里听到您的问候。谢谢不是答案,但这是什么意思
$(document).ready(function() {
var myLatLng = new google.maps.LatLng(24.86802, 67.06416);
MYMAP.init('#map', myLatLng, 11);
$(document).ready(function(e){
MYMAP.placeMarkers('testasp.asp');
});
});
为什么要嵌套document.ready?照办
$(document).ready(function() {
var myLatLng = new google.maps.LatLng(24.86802, 67.06416);
MYMAP.init('#map', myLatLng, 11);
MYMAP.placeMarkers('testasp.asp');
});
供活动使用
google.maps.event.addListener([ mapObject ], 'bounds_changed', function() {
// [ update code here ]
});
我想做的是先初始化映射,然后初始化标记,但根据您的更正,您认为它会重新加载或刷新来自MYMAP.placeMarkers'testasp.asp'的标记吗??????