strava map jagged fix - issue was the conversion of gps coord to string

didn't have enough precision.

Found all (most) of the gps coord to string conversions and used a constant
  to insure all conversions occur with the same precision.


Signed-off-by: Greg Lonnon <greg.lonnon@gmail.com>
This commit is contained in:
Greg Lonnon
2012-02-04 05:46:08 -07:00
parent 82704499a8
commit 8ef41d95a5
4 changed files with 33 additions and 28 deletions

View File

@@ -243,7 +243,10 @@ void GoogleMapControl::createHtml()
" webBridge.drawOverlays();\n"
"}\n"
"</script>\n").arg(minLat,0,'g',11).arg(minLon,0,'g',11).arg(maxLat,0,'g',11).arg(maxLon,0,'g',11);
"</script>\n").arg(minLat,0,'g',GPS_COORD_TO_STRING).
arg(minLon,0,'g',GPS_COORD_TO_STRING).
arg(maxLat,0,'g',GPS_COORD_TO_STRING).
arg(maxLon,0,'g',GPS_COORD_TO_STRING);
// the main page is rather trivial
currentPage += QString("</head>\n"
@@ -280,7 +283,7 @@ GoogleMapControl::drawShadedRoute()
" path = polyline.getPath();\n");
} else {
if (rfp->lat || rfp->lon)
code += QString("path.push(new google.maps.LatLng(%1,%2));\n").arg(rfp->lat,0,'g',11).arg(rfp->lon,0,'g',11);
code += QString("path.push(new google.maps.LatLng(%1,%2));\n").arg(rfp->lat,0,'g',GPS_COORD_TO_STRING).arg(rfp->lon,0,'g',GPS_COORD_TO_STRING);
}
// running total of time
@@ -355,20 +358,20 @@ GoogleMapControl::createMarkers()
code = QString("{ var latlng = new google.maps.LatLng(%1,%2);"
"var image = new google.maps.MarkerImage('qrc:images/maps/loop.png');"
"var marker = new google.maps.Marker({ icon: image, animation: google.maps.Animation.DROP, position: latlng });"
"marker.setMap(map); }").arg(points[0]->lat,0,'g',11).arg(points[0]->lon,0,'g',11);
"marker.setMap(map); }").arg(points[0]->lat,0,'g',GPS_COORD_TO_STRING).arg(points[0]->lon,0,'g',GPS_COORD_TO_STRING);
view->page()->mainFrame()->evaluateJavaScript(code);
} else {
// start / finish markers
code = QString("{ var latlng = new google.maps.LatLng(%1,%2);"
"var image = new google.maps.MarkerImage('qrc:images/maps/cycling.png');"
"var marker = new google.maps.Marker({ icon: image, animation: google.maps.Animation.DROP, position: latlng });"
"marker.setMap(map); }").arg(points[0]->lat,0,'g',11).arg(points[0]->lon,0,'g',11);
"marker.setMap(map); }").arg(points[0]->lat,0,'g',GPS_COORD_TO_STRING).arg(points[0]->lon,0,'g',GPS_COORD_TO_STRING);
view->page()->mainFrame()->evaluateJavaScript(code);
code = QString("{ var latlng = new google.maps.LatLng(%1,%2);"
"var image = new google.maps.MarkerImage('qrc:images/maps/finish.png');"
"var marker = new google.maps.Marker({ icon: image, animation: google.maps.Animation.DROP, position: latlng });"
"marker.setMap(map); }").arg(points[points.count()-1]->lat,0,'g',11).arg(points[points.count()-1]->lon,0,'g',11);
"marker.setMap(map); }").arg(points[points.count()-1]->lat,0,'g',GPS_COORD_TO_STRING).arg(points[points.count()-1]->lon,0,'g',GPS_COORD_TO_STRING);
view->page()->mainFrame()->evaluateJavaScript(code);
}
@@ -414,7 +417,7 @@ GoogleMapControl::createMarkers()
"var image = new google.maps.MarkerImage('qrc:images/maps/cycling_feed.png');"
"var marker = new google.maps.Marker({ icon: image, animation: google.maps.Animation.DROP, position: latlng });"
"marker.setMap(map);"
"}").arg(rfp->lat,0,'g',11).arg(rfp->lon,0,'g',11);
"}").arg(rfp->lat,0,'g',GPS_COORD_TO_STRING).arg(rfp->lon,0,'g',GPS_COORD_TO_STRING);
view->page()->mainFrame()->evaluateJavaScript(code);
stoptime=0;
}
@@ -440,8 +443,8 @@ GoogleMapControl::createMarkers()
" markerList.push(marker);" // keep track of those suckers
" google.maps.event.addListener(marker, 'click', function(event) { webBridge.toggleInterval(%4); });"
"}")
.arg(myRideItem->ride()->dataPoints()[offset]->lat,0,'g',11)
.arg(myRideItem->ride()->dataPoints()[offset]->lon,0,'g',11)
.arg(myRideItem->ride()->dataPoints()[offset]->lat,0,'g',GPS_COORD_TO_STRING)
.arg(myRideItem->ride()->dataPoints()[offset]->lon,0,'g',GPS_COORD_TO_STRING)
.arg(x.name)
.arg(interval);
view->page()->mainFrame()->evaluateJavaScript(code);
@@ -486,10 +489,10 @@ void GoogleMapControl::zoomInterval(IntervalItem *which)
"var northeast = new google.maps.LatLng(%3, %4);\n"
"var bounds = new google.maps.LatLngBounds(southwest, northeast);\n"
"map.fitBounds(bounds);\n }")
.arg(minLat,0,'g',11)
.arg(minLon,0,'g',11)
.arg(maxLat,0,'g',11)
.arg(maxLon,0,'g',11);
.arg(minLat,0,'g',GPS_COORD_TO_STRING)
.arg(minLon,0,'g',GPS_COORD_TO_STRING)
.arg(maxLat,0,'g',GPS_COORD_TO_STRING)
.arg(maxLon,0,'g',GPS_COORD_TO_STRING);
view->page()->mainFrame()->evaluateJavaScript(code);
}