/// <summary> /// Draw on the google map /// </summary> /// <param name="data"></param> public void GpsIntervalDraw(List <DrawMap.gpsData> data) { //create the placemark KmlPlacemarkCoClass lineStringPlacemark = ge.createPlacemark(""); //create the LineString IKmlLineString lineString = ge.createLineString(""); lineStringPlacemark.setGeometry(lineString); for (int i = 0; i < data.Count; i++) { double latitude = data[i].latitude; double longitude = data[i].longitude; //add lineString points lineString.getCoordinates().pushLatLngAlt(latitude, longitude, 0); } //add the feature to Earth ge.getFeatures().appendChild(lineStringPlacemark); }
public void ResetPath() { var ridingPathFolder = (IKmlFolder)ge.getElementById("ridingPath"); if (ridingPathFolder != null) { var features = ridingPathFolder.getFeatures(); IKmlObject firstChild = null; while ((firstChild = features.getFirstChild()) != null) { features.removeChild(firstChild); } } this.pointsInSection = 0; this.currentSection = null; }
public void AddPoint(GeoCoordinate gc, bool createNew, bool resetPath) { // Some constants string pathColor = "ff00ffff"; float pathWidth = 2; var ridingPathFolder = (IKmlFolder)ge.getElementById("ridingPath"); if (ridingPathFolder == null) { if (createNew) { ridingPathFolder = ge.createFolder("ridingPath"); ge.getFeatures().appendChild(ridingPathFolder); // ridingPathStyle = ge.createStyle("ridingPathStyle"); ridingPathStyle.getLineStyle().getColor().set(pathColor); ridingPathStyle.getLineStyle().setWidth(pathWidth); } else { return; } } if (resetPath) { ResetPath(); } if (pointsInSection == 0) // Create new Placemark with new LineString { // Create the placemark var lineStringPlacemark = ge.createPlacemark(""); // Create the LineString this.currentSection = ge.createLineString(""); lineStringPlacemark.setGeometry(this.currentSection); this.currentSection.setExtrude(0); this.currentSection.setTessellate(1); this.currentSection.setAltitudeMode(ge.ALTITUDE_CLAMP_TO_GROUND); // Add the feature to Earth ridingPathFolder.getFeatures().appendChild(lineStringPlacemark); lineStringPlacemark.setStyleSelector(ridingPathStyle); } if (pointsInSection++ >= 65000) { pointsInSection = 0; } this.currentSection.getCoordinates().pushLatLngAlt(gc.Latitude, gc.Longitude, 0); //=================// // Handle 3D model // //=================// if (this.ShowModel == true && this.geWebBrowser != null) { LoadTrainModel(); double azimuth = 0; if (this.ridingPath.Count > 1) { double p_lat = this.ridingPath[this.ridingPath.Count - 1].Latitude; double p_lon = this.ridingPath[this.ridingPath.Count - 1].Longitude; FC.GEPluginCtrls.Geo.Coordinate p_c = new FC.GEPluginCtrls.Geo.Coordinate(latitude: p_lat, longitude: p_lon); FC.GEPluginCtrls.Geo.Coordinate c = new FC.GEPluginCtrls.Geo.Coordinate(latitude: gc.Latitude, longitude: gc.Longitude); azimuth = FC.GEPluginCtrls.Geo.Maths.BearingInitial(p_c, c); } SetTrainModel(gc.Latitude, gc.Longitude, azimuth); } this.ridingPath.Add(gc); }
private void btRuler_Click(object sender, EventArgs e) { if (!rulerMode) //If the program isn't in ruler mode { //Okay so this function will allow the user to create points on the map that will be used to calculate distance //between a path. //So the first we'll have to do is call the JsCrt function which readies the double click event handler. webBrowser1.Document.InvokeScript("JSrulerPoint", new object[] { }); //So now the map will be ready for a double click rulerMode = true; this.btRuler.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.hover)); // This will leave the colour on, giving the user an indication that rulerMode is still on. IKmlPlacemark newLine = ge.createPlacemark("line"+lineNumber); IKmlLineString newLinePoints = ge.createLineString("linePoints" + lineNumber); IKmlFolder rulerConstruct = ge.createFolder("construct"+lineNumber); ++lineNumber; line = newLine; linePoints = newLinePoints; ruler = rulerConstruct; ruler.getFeatures().appendChild(line); ge.getFeatures().appendChild(ruler); rulerPanel.Visible = true; } else { //Now the user has completed measuring the path, so now we should delete the points that were created and call of the double click event handler webBrowser1.Document.InvokeScript("JSrmCT", new object[] {} ); this.btRuler.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.normal)); //This will put the colour back to normal, giving the user an indication that rulerMode is off. rulerMode = false; ge.getFeatures().removeChild(ruler); rulerDistance = 0; rulerDistanceText.Text = ""; pointsMeasured = 0; rulerPanel.Visible = false; } }
public Boolean insert(String tp1, String tp2) { try { // Get the end placemark of the 1st trip and the start placemark of the second trip IKmlPlacemark tp1fn = t_pool.getFinish(t_pool.getByName(tp1)); IKmlPlacemark tp2st = t_pool.getStart(t_pool.getByName(tp2)); //create a place mark to store the new place mark IKmlPlacemark start = ge.createPlacemark(""); IKmlPlacemark finish = ge.createPlacemark(""); start.setName(tp1fn.getName()); finish.setName(tp2st.getName()); IKmlPoint sp = ge.createPoint(""); IKmlPoint fp = ge.createPoint(""); IKmlPlacemark _temp = ge.createPlacemark(""); IKmlLineString temp = ge.createLineString(""); // Retrieve the coordinates of the two trips Hashtable cds1 = Module.getCoordinates(tp1fn); Hashtable cds2 = Module.getCoordinates(tp2st); sp.setLatLng((double)cds1["lat"], (double)cds1["lon"]); start.setGeometry(sp); fp.setLatLng((double)cds2["lat"], (double)cds2["lon"]); finish.setGeometry(fp); String color = randomCol(); IKmlStyleMap sm = ge.createStyleMap(""); IKmlStyle normal = mkStyle(color, @"http://maps.google.com/mapfiles/kml/paddle/wht-blank.png", (float)0.3); IKmlStyle highlight = mkStyle(color, @"http://maps.google.com/mapfiles/kml/paddle/wht-blank.png", (float)0.4); sm.setNormalStyle(normal); sm.setHighlightStyle(highlight); start.setStyleSelector(sm); finish.setStyleSelector(sm); temp.getCoordinates().pushLatLngAlt((double)cds1["lat"], (double)cds1["lon"], 0); temp.getCoordinates().pushLatLngAlt((double)cds2["lat"], (double)cds2["lon"], 0); _temp.setGeometry(temp); IKmlStyle sty = ge.createStyle(""); sty.getLineStyle().setWidth((float)4); sty.getLineStyle().getColor().set(color); _temp.setStyleSelector(sty); //create a new KML folder for the new trip and append the tmp features of the previous trip IKmlFolder temp1 = ge.createFolder(""); temp1.getFeatures().appendChild(start); temp1.getFeatures().appendChild(_temp); temp1.getFeatures().appendChild(finish); String[] attributes = new String[14]; //Add the new trip to the trip pools t_pool.add(tp2, temp1, attributes); ge.getFeatures().appendChild(temp1); // record the insert action for undo action record.ins_trip(tp2); return(true); } catch { return(false); } }