PHP增量运算符不能在我的代码中工作,我不知道为什么。这是我的代码:
for(var j=0; j<=COUNTLatitud;j++) {
<?php $incremento=0; ?>
valor1=<?php echo (float)$Latitud[$incremento];?>;
valor2=<?php echo (float)$Longitud[$incremento];?>;
point = new google.maps.LatLng(<valor1,valor2);
<?php $incremento=$incremento+1; ?>
iconoMarcador = new google.maps.MarkerImage( 'https://dl.dropboxusercontent.com/s/d4x1b4qtqhbvfwn/office-building.png', new google.maps.Size(32, 37), new google.maps.Point(0,0), new google.maps.Point(9, 34) );
if( google.maps.geometry.poly.containsLocation( point, miPoligono ) ) {
marcador = new google.maps.Marker( {
map: miMapa,
position: point,
icon: iconoMarcador
} );
}
}
我使用JavaScript + PHP,当我创建一个console.log(j)时,for正常工作。
(变量在上面声明)
任何线索?我想哭。
答案 0 :(得分:0)
好的,我用这种方式处理了我的问题:
function marcadores(){
var valor1=new Array();
var valor2=new Array();
var point;
var marcador;
var iconoMarcador;
var arrayLat=<?php echo json_encode($Latitud);?>;
var arrayLon=<?php echo json_encode($Longitud);?>;
for(var j=0; j<=COUNTLatitud;j++) {
point = new google.maps.LatLng(arrayLat[j],arrayLon[j]);
iconoMarcador = new google.maps.MarkerImage( 'https://dl.dropboxusercontent.com/s/d4x1b4qtqhbvfwn/office-building.png', new google.maps.Size(32, 37), new google.maps.Point(0,0), new google.maps.Point(9, 34) );
if( google.maps.geometry.poly.containsLocation( point, miPoligono ) ) {
marcador = new google.maps.Marker( {
map: miMapa,
position: point,
icon: iconoMarcador
} );
}
}
}
我希望帮助一些人:)