javascript - Trouble with google maps api v3 polyline and markers -


well im making gps tracking app , gps sending data database need fetch data , use api, app suposed draw route of 1 given car id. code

for($i=0;$i<sizeof($losdatos);$i++) { if($losdatos[$i+1]['latitud']<>$losdatos[$i]['latitud'] || $losdatos[$i+1]['longitud']<>$losdatos[$i]['longitud']) { $script.="latarray.push(".$losdatos[$i]['latitud'].");"; $script.="lngarray.push(".$losdatos[$i]['longitud'].");"; $script.="codigos.push(".$losdatos[$i]['codigo'].");"; $script.="fechas.push('".$losdatos[$i]['fecha']."');"; $script.="velocidades.push(".$losdatos[$i]['velocidad'].");"; } } 

once ive filled array call function of mine called route. parameters in function arrays

 route(latarray,lngarray,codigos,fechas,velocidades);   function route(lats,lngs,codigos,fechas,vs,weight) { var pointsarray=[]; //make new point each lat,lng  for(i=0;i<latarray.length;i++)     {     pointsarray.push(new google.maps.latlng(lats[i],lngs[i]));      //this next function adds marker , sets infowindow code,date , speed each one.     addmarker(lats[i],lngs[i],codigos[i],fechas[i],vs[i]);     }  //then send pointsarray polyline  var ruta = new google.maps.polyline({     path: pointsarray,     strokecolor: "#ff0000",     strokeopacity: 0.5,     strokeweight: weight});  ruta.setmap(map); } 

the trouble polyline points , marker points not match 30 pixels away each other when supposed in same location

well problem solved had problem image size using thin

var marker = new google.maps.marker({             position: pos,              map: map,                 icon:'img/bluedot.png'  }); 

but seemed needed more specific did this

var icon=new google.maps.markerimage('img/bluedot.png',new google.maps.size(6,6),new google.maps.point(0,0),new google.maps.point(0,1));   var marker = new google.maps.marker({                 position: pos,                  map: map,                         icon:icon      }); 

Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -