我得到了关于如何使折线位于中心的问题的答案,但这就是问题。当我想看地图的时候。地图仅在我的 div 的左上角初始化。当我调用这个函数时:
setTimeout(function() {
google.maps.event.trigger(map,'resize');
}, 200);
Run Code Online (Sandbox Code Playgroud)
我可以在整个 div 中看到地图,但折线未缩放并且位于左上角内。
我应该怎么办?
我的代码:
全局定义:
var flightPlanCoordinates=[];
var flightPath;
var map;
var myLatLng = new google.maps.LatLng(0, 0);
var mapOptions = {
zoom: 5,
center: myLatLng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
Run Code Online (Sandbox Code Playgroud)
后来用了代码...
$.ajax({
type: 'POST',
url: 'history.php',
data: {
'd_year1':$('#select-choice-year1').val(),
'd_month1': $('#select-choice-month1').val(),
'd_day1':$('#select-choice-day1').val(),
'd_year2':$('#select-choice-year2').val(),
'd_month2': $('#select-choice-month2').val(),
'd_day2':$('#select-choice-day2').val()
},
success: function(data)//callback to be executed when the response has been received
{
if(data=="[]")
{
alert("None");
}else
{
data = JSON.parse(data);
for (var i=0;i<data.length;i++)
{
flightPlanCoordinates[i] = …Run Code Online (Sandbox Code Playgroud)