I am trying to plot the polyline on Google Map for Flutter Web. I am calling the directions API and using "overview_polyline" then parsing the result into List points to plot it into the polyline. I have tried several methods and i do get the polyline but corrupted as the below image.
PolylinePoints polylinePoints = PolylinePoints();
List<PointLatLng> result = polylinePoints.decodePolyline("atnwF`jubM_kCrzPbaDbnQpmG~wj#ttEd~`B_`Fvdj#i{#xlHrxDtxKlvLfoYKxxv#`dBpc|#bbPzl}#lbWvfrAv}RxtbA|wPxryBt`Pbch#f}#hka#`sMfea#myCnpZeaGt~V|rKlba#`nCnmXcsLrhq#}bKvwS{xCnfXm|Gvm]kjG|ed#jbK~rY~oBtt[__Fbhk#wpBbvMzsGbzIpwC||ZhcK`uYkuAlpsArdDndgAltJv`gAx}FrybEitFtw~AngRzpgCpcGt~sBxq#fmk#k~Ehz]vaAfs~AteFr`~AnxBhrTpcN`iBd|#rel#bx`#~q~A`zO|{nAzVtfr#vzC~yj#|iZrgnAxrQvtr#h`Hhoi#zgNnrXdgMdpo#jdHn{t#|n]`|pAbjDjrg#nhLpz^`oNvyg#x_Idqd#|zQz}wAdi^v{j#nd\\la`#tkXfhy#dtL`em#jgH|dg#heOfp\\nkHf{f#n~BlrY|~HlwYlg\\hsa#jz]|jRzhNr_LpvGdi\\vvEzgn#p`K~ez#doQfug#zmAvsgBtq]jyhAvjPtaP~xP~wG`jWpms#t_[tf^`b^rtm#`rZxj`#rgRbq|#pwW`wd#hfWnlo#nb]`_uBvxH`}kB|q[zhGy~Ip`z#obAdncB`~Ej_zA|rMpngAnzIhlb#h|RhwQfmEdtqBxwAvq`B~hElxa#eyCfx{#auAz~o#brDdwj#dQzj{#osN|aiCnbP`geAtsId|^afAjwc#cjDxlq#dyHd{c#phJ~quAheUlabAulGndmBuhBxw`By#hxh#goGlfi#qhKhmb#h{E`kb#uwDfxX~rFlwY`kKl_s#lUffq#qlHlif#gxA`cc#{rMhp\\gwW`|XseS`sOo_D|n[goLxud#m~Lf{t#lnHpek#t|T~xXldQp~ZjvQdst#ja[xteAlkIzgf#xhI~gUrrD|iLecFx{OmqDzqa#ucIboi#srP`ohAipPzndAy~Alv^dtEjcXseHl_TinDb_i#phAdfc#nqD`ql#_nIb{x#knGzij#vrDnw\\bxQ~kl#~wDzae#qmGhjdBti[hkKrah#f~BxmPllKpeEf_]ci#fqc#mx\\r}XndFhds#psPbtgBx}Dj|pApRtak#}_Kn_~#auGhat#}gHfyn#rE|hUyhFtnKgoGbqw#obHjyy#avBje~#s}Kp~KirBvqTegAz}^qnPnnZyyKvh`#ksMrvr#ubCjlKaiIngCaeRdyVegm#f~J_qgA~}M_mg#nbQk|SbdLme\\inDgzXzq#qkIkvIQ~Y");
for (var point in result) {
points.add(LatLng(point.latitude, point.longitude));
}
polyLine.add(Polyline(polylineId: PolylineId('1'),points: points,width: 7,color: Colors.blue));
i have tried to use start_location and end_location values but unfortuantly they don't return the specifix coordinates for the road. the overall route is correct but not pined to the road.
Related
I'm using the Flutter SDK Version 4.3.1.0.
I get my location updates from the geolocator plugin and want to show the location on the HERE map. It correctly centers the map to the current location but there is no location indicator.
I currently use the following code. What else do I need?
void _showPosition(final GeoCoordinates coordinates) {
_mapView.mapScene.loadSceneForMapScheme(MapScheme.greyDay, (MapError error) {
if (error != null) {
print("Map scene not loaded. MapError: " + error.toString());
return;
}
_mapView.camera.lookAtPointWithDistance(coordinates, 1000);
});
}
I'm using the Flutter Channel beta, v1.17.0-3.4.pre
The HERE SDK for Flutter does not contain a pre-configured location indicator. You can easily create one by adding a circle item onto the map:
For this I would recommend using a MapPolygon that contains a GeoCircle shape. You can then also update the radius of the GeoCircle on the fly to indicate the current horizontal accuracy of the geolocator plugin.
I have a Bing map with drawing manager enabled for users to draw shapes (mostly one polygon at a time). I want to be able to get the details of the drawn polygon so I can save it in the database.
The below function can access the shapes but returns the coordinates only
function getShapes()
{
var shapes = drawingManager.getPrimitives();
if (shapes && shapes.length > 0)
{
var rings = shapes[0].getRings();
alert('Retrieved ' + rings[0] + ' from the drawing manager.');
}
else
{
alert('No shapes in the drawing manager.');
}
}
result is:
Retrieved [MapLocation (35.17314901376581, 44.72432011035158)],[MapLocation (35.10324034213123, 44.73015659716798)],[MapLocation (35.12346106720259, 44.90525120166017)],[MapLocation (35.18633788986748, 44.88362186816408)],[MapLocation (35.17314901376581, 44.72432011035158)] from the drawing manager.
How can I get the exact drawn shape details not just the coordinates?
Remove getRings() and you will have the shape object. The Get Rings function retudrrns the coordinates of a polygon.
How I can delete the polyline line between 2 specific marker.
I have many polyline connected with many marker . But i want to delete any sspecific line on double click .
How Can I do that ?
I am using leaflet to draw the polyline.
here suppose I want to delete the polyline between marker 3 and 4 on double click. what will be procedure to do that.
Thank you.
I tried something like this but its not working , Can anybody please help me where is the mistakes ?
//polyline delete on double click
for (var i = 0; i < $scope.polycoords.length; i++) {
var polyline = $scope.polycoords[i];
$scope.polycoords[i].on('click', function (e) {
console.log("sdd",polyline._leaflet_id);
for (var j = 0; j < $scope.polycoords.length; j++) {
if($scope.polycoords[i]._leaflet_id = $scope.polycoords[j]._leaflet_id){
console.log($scope.polycoords[j])
var polyline = $scope.polycoords[j];
map.removeLayer(polyline);
}
}
});
}
polyline.on('dblclick', function (e) {
map.removeLayer(this);
});
Edit
This is going to work because based on your other question here on SO, I know that you create a different polyline for each line. But for anyone else that creates a single polyline with all the coordinates together, this solution will delete the whole polyline, not just a part of it.
Is it possible to cluster only markers on the same coordinates?
When using mapbox marker clustering all markers are grouped depending on map zoom level. What I would like to do is to have all markers independent (non grouped) except markers on the same latitude-longitude coordinates.
Is that possible?
This is not a perfect solution but it will do the job...
I've solved my problem by using two layer groups, one for individual markers and one for clustered markers.
Something like this:
var overlay1 = L.layerGroup().addTo(map);//this one is for single markers
var overlay2 = L.layerGroup().addTo(map);//this one is for clustered
var layers;
//load markers from external source
var featureLayer = L.mapbox.featureLayer()
.loadURL('/my_geojson_script/')
.on('ready', function(e) {
layers = e.target;
//go and do the filtering
doTheThing();
})
function doTheThing()
overlay1.clearLayers();//remove all single markers
overlay2.clearLayers();//remove all clustered
var clusterGroup = new L.MarkerClusterGroup().addTo(overlay2);
layers.eachLayer(function(layer) {
//the number of markers on this layer coordinates (info collected from json property. I calculate this in advance)
var numberOfMarkers = layer.feature.properties.numberOfMarkers;
//if number of markers is greater than 1 add layer to cluster group
if(numberOfMarkers>1){
clusterGroup.addLayer(layer);
}
else{//if number of markers is 1 add layer to individual layer group
overlay1.addLayer(layer);
}
});
}
I've been playing with the google earth API. I thought it would be neat to draw some lines between places from a relative 3D viewpoint. I've searched through the GE documentation and searched on google for answers but didn't find anything that led me down the correct path, so I thought I'd post some code and perhaps get some insight.
The following code plots two places and then draws a line between those places. Unfortunately the line that gets drawn splices the earth. Is there a method to make it wrap to the contour of the earth when drawn in 3D like this? I've attempted to vary the line height placement with a varying degree of success, but at the cost of accuracy and overall visual appeal when the line doesn't appear to connect the places.
function init() {
google.earth.createInstance('map3d', initCB, failureCB);
}
function initCB(instance) {
ge = instance;
ge.getWindow().setVisibility(true);
//---------------------------------PLACES
// Create the placemark.
var placemark = ge.createPlacemark('');
placemark.setName("Location 1");
// Set the placemark's location.
var point = ge.createPoint('');
point.setLatitude(39.96028);
point.setLongitude(-82.979736);
placemark.setGeometry(point);
// Add the placemark to Earth.
ge.getFeatures().appendChild(placemark);
// Create the placemark.
var placemark2 = ge.createPlacemark('');
placemark2.setName("Hop #2");
// Set the placemark's location.
var point2 = ge.createPoint('');
point2.setLatitude(25.7615);
point2.setLongitude(-80.2939);
placemark2.setGeometry(point2);
// Add the placemark to Earth.
ge.getFeatures().appendChild(placemark2);
//---------------------------------FOCUS
var lookAt = ge.createLookAt('');
lookAt.setLatitude(39.96028);
lookAt.setLongitude(-82.979736);
lookAt.setRange(1000000.0);
lookAt.setAltitude(0);
lookAt.setTilt(45);
ge.getView().setAbstractView(lookAt);
//---------------------------------LINES
// Create the placemark
var lineStringPlacemark = ge.createPlacemark('');
// Create the LineString
var lineString = ge.createLineString('');
lineStringPlacemark.setGeometry(lineString);
// Add LineString points
lineString.getCoordinates().pushLatLngAlt(39.96028, -82.979736, 0);
lineString.getCoordinates().pushLatLngAlt(25.7615, -80.2939, 0);
//lineString.setAltitudeMode(ge.ALTITUDE_CLAMP_TO_GROUND);
//lineString.setAltitudeMode(ge.ALTITUDE_RELATIVE_TO_GROUND);
lineString.setAltitudeMode(ge.absolute);
// Create a style and set width and color of line
lineStringPlacemark.setStyleSelector(ge.createStyle(''));
var lineStyle = lineStringPlacemark.getStyleSelector().getLineStyle();
lineStyle.setWidth(2);
lineStyle.getColor().set('9900ffff'); // aabbggrr format
// Add the feature to Earth
ge.getFeatures().appendChild(lineStringPlacemark);
}
function failureCB(errorCode) {
}
google.setOnLoadCallback(init);
You will want to set tesselation, and optionally extrude, on your linestring to true.
See https://developers.google.com/kml/documentation/kmlreference#tessellate and https://developers.google.com/kml/documentation/kmlreference#extrude for details
For the API, your syntax would be something like
lineStringPlacemark.setTessellate(true);
lineStringPlacemark.setExtrude(true);
There's some additional API examples on this at https://developers.google.com/earth/documentation/geometries