本文整理汇总了Java中org.osmdroid.views.overlay.Polyline类的典型用法代码示例。如果您正苦于以下问题:Java Polyline类的具体用法?Java Polyline怎么用?Java Polyline使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Polyline类属于org.osmdroid.views.overlay包,在下文中一共展示了Polyline类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createRoute
import org.osmdroid.views.overlay.Polyline; //导入依赖的package包/类
/**
* Create route on map
*
* @param fromLatitude Latitude to start drawing, users location
* @param fromLongitude Longitude to start drawing, users location
* @param toLatitude Latitude to end drawing
* @param toLongitude Longitude to end drawing
*/
private void createRoute(double fromLatitude, double fromLongitude, final double toLatitude, final double toLongitude) {
new RouteCreationTask(getActivity(), map, fromLatitude, fromLongitude, toLatitude, toLongitude, new PolylineCallback() {
@Override
public void onPolylineCreated(Polyline polyline) {
existingRoute = polyline;
//clear previously added marker
if (routeDestinationMarker != null)
map.getOverlays().remove(routeDestinationMarker);
//add destination marker if
routeDestinationMarker = MapUtils.addMarker(getActivity(), map, toLatitude, toLongitude);
if (getActivity() != null)
((MainActivity) getActivity()).routeAddedOnMap(routeDestinationMarker, existingRoute);
//start task to redraw the route ever 30 seconds, if no previous timer is set ont this route
if (routeUpdateTimer == null)
overrideRouteOnLocationChange();
}
@Override
public void onFailure() {
new AppToast(getActivity()).centerViewToast(getString(R.string.osm_routing_unavailable));
}
}).execute();
}
开发者ID:CityZenApp,项目名称:Android-Development,代码行数:34,代码来源:MapFragment.java
示例2: onSearchRouteResponse
import org.osmdroid.views.overlay.Polyline; //导入依赖的package包/类
@Override
public void onSearchRouteResponse(final Overlay overlay, final ServerResponse taskStatus) {
// actually plots the route on the map
if(taskStatus == ServerResponse.SUCCESS){
Polyline roadOverlay = (Polyline) overlay;
roadOverlay.setColor(ROUTE_LINE_COLORS.get(ROUTES_COUNTER));
roadOverlay.setWidth(10);
mapView.addOverlay(roadOverlay, OverlayTags.ROUTE);
ROUTES_COUNTER++;
}else if(taskStatus == ServerResponse.TIMEOUT){
Toast.makeText(context, getString(R.string.error_server_timeout), Toast.LENGTH_SHORT).show();
}else if (taskStatus == ServerResponse.CONNECTION_FAILED){
Toast.makeText(context, R.string.error_connection_failed, Toast.LENGTH_SHORT).show();
}else if(ROUTES_COUNTER == MAX_ROUTES){
Toast.makeText(context, R.string.msg_routes_limit, Toast.LENGTH_SHORT).show();
}
(getActivity().findViewById(R.id.progress_bar)).setVisibility(View.INVISIBLE);
}
开发者ID:smartufpa,项目名称:SmartUFPA,代码行数:19,代码来源:MapFragment.java
示例3: setPolyline
import org.osmdroid.views.overlay.Polyline; //导入依赖的package包/类
public void setPolyline(Polyline newPolyline){
if (oldPolyline != null){
oldPolyline.remove();
}
if (newPolyline == null){
return;
}
PolylineOptions options = new PolylineOptions()
.color(newPolyline.getColor())
.visible(newPolyline.isVisible())
.width(newPolyline.getWidth())
;
for (GeoPoint p : newPolyline.getPoints()){
options.add(new LatLng(p.getLatitude(), p.getLongitude()));
}
oldPolyline = map.addPolyline(options);
}
开发者ID:RSDT,项目名称:Japp16,代码行数:19,代码来源:Navigator.java
示例4: calcRoute
import org.osmdroid.views.overlay.Polyline; //导入依赖的package包/类
/**
* Calculates a route from your start location to the next bus stop
*/
private void calcRoute()
{
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();//Strict mode for ignore NetworkOnMainExceptions (!for anytime, have to put in threading)
StrictMode.setThreadPolicy(policy);
ArrayList<GeoPoint> waypoints = new ArrayList<GeoPoint>(); //Build up list of geopoints
waypoints.add(currenLocation);
GeoPoint endPoint = new GeoPoint(destinationLocation);
waypoints.add(endPoint);
Road road = roadManager.getRoad(waypoints);
double d = road.mDuration; // get duration
double x = road.mLength; // get length
String st_timeLeft = String.format("%s min", String.valueOf(myRound(d / 60,3)));//format string
String st_dist = String.valueOf(myRound(x * 1000,2)) + " m";
timeLeft.setText(st_timeLeft);
distGoal.setText(st_dist);
Polyline roadOverlay = RoadManager.buildRoadOverlay(road, Activity2.this);// draw route
mMapView.getOverlays().add(roadOverlay);
mMapView.invalidate();
}
开发者ID:flbbr,项目名称:Run2Stop,代码行数:27,代码来源:Activity2.java
示例5: calcRoute
import org.osmdroid.views.overlay.Polyline; //导入依赖的package包/类
/**
* Calulates a route from current destination to the next bus stop
*/
private void calcRoute()
{
ArrayList<GeoPoint> waypoints = new ArrayList<GeoPoint>();
waypoints.add(currenLocation);
GeoPoint endPoint = new GeoPoint(destinationLocation);
waypoints.add(endPoint);
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
Road road = roadManager.getRoad(waypoints);
double d = road.mDuration;
double x = road.mLength;
Polyline roadOverlay = RoadManager.buildRoadOverlay(road, MainActivity.this);
mMapView.getOverlays().add(roadOverlay);
mMapView.invalidate();
}
开发者ID:flbbr,项目名称:Run2Stop,代码行数:23,代码来源:MainActivity.java
示例6: add
import org.osmdroid.views.overlay.Polyline; //导入依赖的package包/类
protected void add(List<GeoPoint> points, int color) {
Polyline polyline = new Polyline();
polyline.setColor(color);
polyline.setPoints(points);
if (routes.isEmpty()){
initMarker.setPosition(points.get(0));
} else {
Marker marker = getInnerMarker();
marker.setPosition(points.get(0));
//markers.add(marker);
}
this.routes.add(polyline);
endMarker.setPosition(points.get(points.size()-1));
hideMarkers = false;
this.setDirty(true);
}
开发者ID:InspectorIncognito,项目名称:androidApp,代码行数:19,代码来源:PolylineLayer.java
示例7: addOverlay
import org.osmdroid.views.overlay.Polyline; //导入依赖的package包/类
/**
* Converts the overlay to a KmlFeature and add it inside this.
* Conversion from Overlay subclasses to KML Features is as follow: <br>
* FolderOverlay, MarkerClusterer => Folder<br>
* Marker => Point<br>
* Polygon => Polygon<br>
* Polyline => LineString<br>
* GroundOverlay => GroundOverlay<br>
* Else, add nothing.
* @param overlay to convert and add
* @param kmlDoc for style handling.
* @return true if OK, false if the overlay has not been added.
*/
public boolean addOverlay(Overlay overlay, KmlDocument kmlDoc){
if (overlay == null)
return false;
KmlFeature kmlItem;
if (overlay instanceof GroundOverlay){
kmlItem = new KmlGroundOverlay((GroundOverlay)overlay);
} else if (overlay instanceof FolderOverlay){
kmlItem = new KmlFolder((FolderOverlay)overlay, kmlDoc);
} else if (overlay instanceof MarkerClusterer){
kmlItem = new KmlFolder((MarkerClusterer)overlay, kmlDoc);
} else if (overlay instanceof Marker){
Marker marker = (Marker)overlay;
kmlItem = new KmlPlacemark(marker);
} else if (overlay instanceof Polygon){
Polygon polygon = (Polygon)overlay;
kmlItem = new KmlPlacemark(polygon, kmlDoc);
} else if (overlay instanceof Polyline){
Polyline polyline = (Polyline)overlay;
kmlItem = new KmlPlacemark(polyline, kmlDoc);
} else {
return false;
}
mItems.add(kmlItem);
return true;
}
开发者ID:MKergall,项目名称:osmbonuspack,代码行数:39,代码来源:KmlFolder.java
示例8: applyDefaultStyling
import org.osmdroid.views.overlay.Polyline; //导入依赖的package包/类
public void applyDefaultStyling(Polyline lineStringOverlay, Style defaultStyle, KmlPlacemark kmlPlacemark,
KmlDocument kmlDocument, MapView map){
Context context = map.getContext();
Style style = kmlDocument.getStyle(kmlPlacemark.mStyle);
if (style != null){
lineStringOverlay.setColor(style.getOutlinePaint().getColor());
lineStringOverlay.setWidth(style.getOutlinePaint().getStrokeWidth());
} else if (defaultStyle!=null && defaultStyle.mLineStyle!=null){
lineStringOverlay.setColor(defaultStyle.getOutlinePaint().getColor());
lineStringOverlay.setWidth(defaultStyle.getOutlinePaint().getStrokeWidth());
}
if ((kmlPlacemark.mName!=null && !"".equals(kmlPlacemark.mName))
|| (kmlPlacemark.mDescription!=null && !"".equals(kmlPlacemark.mDescription))
|| (lineStringOverlay.getSubDescription()!=null && !"".equals(lineStringOverlay.getSubDescription()))
){
if (mDefaultLayoutResId == BonusPackHelper.UNDEFINED_RES_ID){
String packageName = context.getPackageName();
mDefaultLayoutResId = context.getResources().getIdentifier("layout/bonuspack_bubble", null, packageName);
}
lineStringOverlay.setInfoWindow(new BasicInfoWindow(mDefaultLayoutResId, map));
}
lineStringOverlay.setEnabled(kmlPlacemark.mVisibility);
}
开发者ID:MKergall,项目名称:osmbonuspack,代码行数:24,代码来源:KmlTrack.java
示例9: buildOverlay
import org.osmdroid.views.overlay.Polyline; //导入依赖的package包/类
/** Build the corresponding overlay.
* Currently: a Polyline of gx:coords */
@Override public Overlay buildOverlay(MapView map, Style defaultStyle, Styler styler, KmlPlacemark kmlPlacemark,
KmlDocument kmlDocument){
Polyline lineStringOverlay = new Polyline();
lineStringOverlay.setGeodesic(true);
lineStringOverlay.setPoints(mCoordinates);
lineStringOverlay.setTitle(kmlPlacemark.mName);
lineStringOverlay.setSnippet(kmlPlacemark.mDescription);
lineStringOverlay.setSubDescription(kmlPlacemark.getExtendedDataAsText());
if (styler != null)
styler.onTrack(lineStringOverlay, kmlPlacemark, this);
else {
applyDefaultStyling(lineStringOverlay, defaultStyle, kmlPlacemark, kmlDocument, map);
}
return lineStringOverlay;
}
开发者ID:MKergall,项目名称:osmbonuspack,代码行数:18,代码来源:KmlTrack.java
示例10: applyDefaultStyling
import org.osmdroid.views.overlay.Polyline; //导入依赖的package包/类
public void applyDefaultStyling(Polyline lineStringOverlay, Style defaultStyle, KmlPlacemark kmlPlacemark,
KmlDocument kmlDocument, MapView map){
Context context = map.getContext();
Style style = kmlDocument.getStyle(kmlPlacemark.mStyle);
if (style != null){
lineStringOverlay.setColor(style.getOutlinePaint().getColor());
lineStringOverlay.setWidth(style.getOutlinePaint().getStrokeWidth());
} else if (defaultStyle!=null && defaultStyle.mLineStyle!=null){
lineStringOverlay.setColor(defaultStyle.getOutlinePaint().getColor());
lineStringOverlay.setWidth(defaultStyle.getOutlinePaint().getStrokeWidth());
}
if ((kmlPlacemark.mName!=null && !"".equals(kmlPlacemark.mName))
|| (kmlPlacemark.mDescription!=null && !"".equals(kmlPlacemark.mDescription))
|| (lineStringOverlay.getSubDescription()!=null && !"".equals(lineStringOverlay.getSubDescription()))
){
if (mDefaultLayoutResId == BonusPackHelper.UNDEFINED_RES_ID){
String packageName = context.getPackageName();
mDefaultLayoutResId = context.getResources().getIdentifier("layout/bonuspack_bubble", null, packageName);
}
lineStringOverlay.setInfoWindow(new BasicInfoWindow(mDefaultLayoutResId, map));
}
lineStringOverlay.setEnabled(kmlPlacemark.mVisibility);
}
开发者ID:MKergall,项目名称:osmbonuspack,代码行数:24,代码来源:KmlLineString.java
示例11: buildOverlay
import org.osmdroid.views.overlay.Polyline; //导入依赖的package包/类
/** Build the corresponding Polyline overlay */
@Override public Overlay buildOverlay(MapView map, Style defaultStyle, Styler styler, KmlPlacemark kmlPlacemark,
KmlDocument kmlDocument){
Polyline lineStringOverlay = new Polyline();
lineStringOverlay.setGeodesic(true);
lineStringOverlay.setPoints(mCoordinates);
lineStringOverlay.setTitle(kmlPlacemark.mName);
lineStringOverlay.setSnippet(kmlPlacemark.mDescription);
lineStringOverlay.setSubDescription(kmlPlacemark.getExtendedDataAsText());
if (styler != null)
styler.onLineString(lineStringOverlay, kmlPlacemark, this);
else {
applyDefaultStyling(lineStringOverlay, defaultStyle, kmlPlacemark, kmlDocument, map);
}
return lineStringOverlay;
}
开发者ID:MKergall,项目名称:osmbonuspack,代码行数:17,代码来源:KmlLineString.java
示例12: toPolyline
import org.osmdroid.views.overlay.Polyline; //导入依赖的package包/类
/**
* Convert a {@link LineString} to a {@link PolylineOptions}
*
* @param lineString
* @return
*/
public Polyline toPolyline(LineString lineString) {
Polyline line = new Polyline();
if (polylineOptions!=null) {
line.setTitle(polylineOptions.getTitle());
line.setColor(polylineOptions.getColor());
line.setGeodesic(polylineOptions.isGeodesic());
line.setWidth(polylineOptions.getWidth());
line.setSubDescription(polygonOptions.getSubtitle());
}
List<GeoPoint> pts = new ArrayList<>();
for (Point point : lineString.getPoints()) {
GeoPoint latLng = toLatLng(point);
pts.add(latLng);
}
line.setPoints(pts);
return line;
}
开发者ID:osmdroid,项目名称:osmdroid,代码行数:27,代码来源:OsmMapShapeConverter.java
示例13: onPostExecute
import org.osmdroid.views.overlay.Polyline; //导入依赖的package包/类
@Override
protected void onPostExecute(Road[] roads) {
double minLength = 0;
Road bestRoad = null;
roadList = roads;
if (roads == null)
return;
if (roads[0].mStatus == Road.STATUS_TECHNICAL_ISSUE) {
Toast.makeText(activity, "Technical issue when getting the route", Toast.LENGTH_SHORT).show();
} else if (roads[0].mStatus > Road.STATUS_TECHNICAL_ISSUE) { //functional issues
Toast.makeText(activity, "No possible route here", Toast.LENGTH_SHORT).show();
}
List<Overlay> mapOverlays = map.getOverlays();
for (Road road : roads) {
if(road.mLength < minLength || minLength == 0) {
minLength = road.mLength;
bestRoad = road;
}
}
String routeDesc = bestRoad.getLengthDurationText(activity, -1);
Polyline roadPolyline = RoadManager.buildRoadOverlay(bestRoad);
roadPolyline.setTitle(getString(R.string.app_name) + " - " + routeDesc);
roadPolyline.setInfoWindow(new BasicInfoWindow(org.osmdroid.bonuspack.R.layout.bonuspack_bubble, map));
mapOverlays.add(0, roadPolyline);
map.invalidate();
}
开发者ID:CMPUT301F16T01,项目名称:Carrier,代码行数:28,代码来源:DriverViewRequestActivity.java
示例14: onPostExecute
import org.osmdroid.views.overlay.Polyline; //导入依赖的package包/类
@Override
protected void onPostExecute(Road[] roads) {
double minLength = 0;
Road bestRoad = null;
roadList = roads;
if (roads == null)
return;
if (roads[0].mStatus == Road.STATUS_TECHNICAL_ISSUE) {
Toast.makeText(activity, "Technical issue when getting the route", Toast.LENGTH_SHORT).show();
} else if (roads[0].mStatus > Road.STATUS_TECHNICAL_ISSUE) { //functional issues
Toast.makeText(activity, "No possible route here", Toast.LENGTH_SHORT).show();
}
List<Overlay> mapOverlays = map.getOverlays();
for (Road road : roads) {
if(road.mLength < minLength || minLength == 0) {
minLength = road.mLength;
bestRoad = road;
}
}
String routeDesc = bestRoad.getLengthDurationText(activity, -1);
bundle.putDouble("distance", bestRoad.mLength);
bundle.putDouble("duration", bestRoad.mDuration);
Polyline roadPolyline = RoadManager.buildRoadOverlay(bestRoad);
roadPolyline.setTitle(getString(R.string.app_name) + " - " + routeDesc);
roadPolyline.setInfoWindow(new BasicInfoWindow(org.osmdroid.bonuspack.R.layout.bonuspack_bubble, map));
mapOverlays.add(0, roadPolyline);
map.invalidate();
}
开发者ID:CMPUT301F16T01,项目名称:Carrier,代码行数:31,代码来源:ViewLocationsActivity.java
示例15: onPostExecute
import org.osmdroid.views.overlay.Polyline; //导入依赖的package包/类
@Override
protected void onPostExecute(Road[] roads) {
double minLength = 0;
Road bestRoad = null;
roadList = roads;
if (roads == null)
return;
if (roads[0].mStatus == Road.STATUS_TECHNICAL_ISSUE) {
Toast.makeText(activity, "Technical issue when getting the route", Toast.LENGTH_SHORT).show();
} else if (roads[0].mStatus > Road.STATUS_TECHNICAL_ISSUE) { //functional issues
Toast.makeText(activity, "No possible route here", Toast.LENGTH_SHORT).show();
}
List<Overlay> mapOverlays = map.getOverlays();
for (Road road : roads) {
if (road.mLength < minLength || minLength == 0) {
minLength = road.mLength;
bestRoad = road;
}
}
String routeDesc = bestRoad.getLengthDurationText(activity, -1);
Polyline roadPolyline = RoadManager.buildRoadOverlay(bestRoad);
roadPolyline.setTitle(getString(R.string.app_name) + " - " + routeDesc);
roadPolyline.setInfoWindow(new BasicInfoWindow(org.osmdroid.bonuspack.R.layout.bonuspack_bubble, map));
mapOverlays.add(0, roadPolyline);
map.invalidate();
}
开发者ID:CMPUT301F16T01,项目名称:Carrier,代码行数:28,代码来源:RiderRequestActivity.java
示例16: onResume
import org.osmdroid.views.overlay.Polyline; //导入依赖的package包/类
@Override
public void onResume() {
super.onResume();
pathOverlay = new Polyline(getContext());
pathOverlay.setColor(ContextCompat.getColor(getContext(), R.color.colorPrimaryDark));
pathOverlay.getPaint().setStrokeWidth(10.0f);
mMapView.getOverlays().add(pathOverlay);
}
开发者ID:erlymon,项目名称:erlymon-monitor-android,代码行数:9,代码来源:ReportFragment.java
示例17: doInBackground
import org.osmdroid.views.overlay.Polyline; //导入依赖的package包/类
@Override
protected Polyline doInBackground(GeoPoint... places) {
// Starts a RoadManager using the key acquired with a Graphhopper account
RoadManager roadManager = new GraphHopperRoadManager(BuildConfig.GRAPHHOPPER_KEY,true);
roadManager.addRequestOption("vehicle=foot");
ArrayList<GeoPoint> wayPoints = new ArrayList<>();
Collections.addAll(wayPoints, places);
// Calculates the route
Road road = roadManager.getRoad(wayPoints);
if( road.mStatus == 0) // succeed
return RoadManager.buildRoadOverlay(road);
taskStatus = ServerResponse.CONNECTION_FAILED;
return null;
}
开发者ID:smartufpa,项目名称:SmartUFPA,代码行数:16,代码来源:SearchRouteTask.java
示例18: onPostExecute
import org.osmdroid.views.overlay.Polyline; //导入依赖的package包/类
@Override
protected void onPostExecute(Polyline routeOverlay) {
super.onPostExecute(routeOverlay);
if(routeOverlay != null){
callback.onSearchRouteResponse(routeOverlay,taskStatus);
}else if(taskStatus.equals(ServerResponse.CONNECTION_FAILED)){
callback.onSearchRouteResponse(null,taskStatus);
}
}
开发者ID:smartufpa,项目名称:SmartUFPA,代码行数:11,代码来源:SearchRouteTask.java
示例19: Navigator
import org.osmdroid.views.overlay.Polyline; //导入依赖的package包/类
public Navigator(final IJotiMap map){
this.map = map;
onFinishedHandler = new Handler(){
@Override
public void handleMessage(Message msg){
if (msg.obj instanceof Polyline){
setPolyline((Polyline) msg.obj);
}
}
};
}
开发者ID:RSDT,项目名称:Japp16,代码行数:12,代码来源:Navigator.java
示例20: setEndLocation
import org.osmdroid.views.overlay.Polyline; //导入依赖的package包/类
public void setEndLocation(LatLng end){
if (Japp.getLastLocation() != null && end != null){
RouteCalculator r = new RouteCalculator(this);
Location start = Japp.getLastLocation();
AsyncTask<LatLng, Void, Polyline> t = r.execute(new LatLng(start.getLatitude(), start.getLongitude()), end);
}
}
开发者ID:RSDT,项目名称:Japp16,代码行数:8,代码来源:Navigator.java
注:本文中的org.osmdroid.views.overlay.Polyline类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论