示例#1
0
        /// <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);
        }
示例#2
0
        /// <summary>
        /// Create look at mode
        /// </summary>
        public void CreateLookAt()
        {
            KmlLookAtCoClass lookAt = ge.createLookAt("");

            lookAt.set(Latitude, Longitude, Altitude, ge.ALTITUDE_RELATIVE_TO_GROUND, 0, 0, Range);
            ge.getView().setAbstractView(lookAt);

            ge.getLayerRoot().enableLayerById(ge.LAYER_ROADS, 1);


            //create a point
            KmlPointCoClass point = ge.createPoint("");

            point.setLatitude(lookAt.getLatitude());
            point.setLongitude(lookAt.getLongitude());

            //create a placemark
            KmlPlacemarkCoClass placemark = ge.createPlacemark("");

            placemark.setName("Start Position");
            placemark.setGeometry(point);

            ge.getFeatures().appendChild(placemark);
        }
示例#3
0
        private void ShowPlaceMarks()
        {
            if (m_ge != null)
            {
                var icon = m_ge.createIcon("");
                icon.setHref("http://maps.google.com/mapfiles/kml/paddle/ylw-blank.png");

                var iconStyle = m_ge.createStyle("");     //create a new style
                iconStyle.getIconStyle().setIcon(icon);   //apply the icon to the style

                var lineStyle = m_ge.createStyle("");
                lineStyle.getLineStyle().setWidth(2);
                lineStyle.getLineStyle().getColor().set("ffff00ff");      // aabbggrr format


                int idx;
                for (idx = 0; idx < placeMarks.Count - 1; ++idx)
                {
                    KmlPointCoClass p1 = m_ge.createPoint(String.Empty);
                    p1.setLatitude(placeMarks[idx].latitude);
                    p1.setLongitude(placeMarks[idx].longitude);

                    KmlPointCoClass p2 = m_ge.createPoint(String.Empty);
                    p2.setLatitude(placeMarks[idx + 1].latitude);
                    p2.setLongitude(placeMarks[idx + 1].longitude);

                    // create a placemark
                    KmlPlacemarkCoClass lineStringPlacemark = m_ge.createPlacemark(String.Empty);
                    var lineString = m_ge.createLineString(String.Empty);
                    lineStringPlacemark.setGeometry(lineString);

                    lineString.setTessellate(10);
                    lineString.setExtrude(10);
                    lineString.getCoordinates().pushLatLngAlt(p1.getLatitude(), p1.getLongitude(), 0);
                    lineString.getCoordinates().pushLatLngAlt(p2.getLatitude(), p2.getLongitude(), 0);

                    // Create a style and set width and color of line
                    lineStringPlacemark.setStyleSelector(lineStyle);


                    KmlPlacemarkCoClass placemark = m_ge.createPlacemark(String.Empty);
                    // create a points
                    KmlPointCoClass point = m_ge.createPoint("");
                    point.setLatitude(p1.getLatitude());
                    point.setLongitude(p1.getLongitude());

                    placemark.setName(placeMarks[idx].Location);
                    placemark.setGeometry(point);

                    placemark.setStyleSelector(iconStyle);     //apply the style to the placemark

                    // add the placemark to the plugin
                    m_ge.getFeatures().appendChild(placemark);
                    m_ge.getFeatures().appendChild(lineStringPlacemark);
                }

                KmlPointCoClass lastPoint = m_ge.createPoint("");
                lastPoint.setLatitude(placeMarks[idx].latitude);
                lastPoint.setLongitude(placeMarks[idx].longitude);

                KmlPlacemarkCoClass lastPlaceMark = m_ge.createPlacemark(String.Empty);
                lastPlaceMark.setName(placeMarks[idx].Location);
                lastPlaceMark.setGeometry(lastPoint);
                lastPlaceMark.setStyleSelector(iconStyle);

                // add the placemark to the plugin
                m_ge.getFeatures().appendChild(lastPlaceMark);
                // set nav ontrols visible.
                m_ge.getNavigationControl().setVisibility(m_ge.VISIBILITY_AUTO);
                // set status barvisible.
                m_ge.getOptions().setStatusBarVisibility(m_ge.VISIBILITY_AUTO);
                m_ge.getLayerRoot().enableLayerById(m_ge.LAYER_ROADS, 0);
                m_ge.getLayerRoot().enableLayerById(m_ge.LAYER_BORDERS, 1);

                // where ge is an instance of GEPlugin.
                var camera = m_ge.getView().copyAsCamera(m_ge.ALTITUDE_RELATIVE_TO_GROUND);

                // set latitude and longitude
                camera.setLatitude(placeMarks[0].latitude);
                camera.setLongitude(placeMarks[0].longitude);
                // Zoom IN.
                camera.setAltitude(camera.getAltitude() / 10);
                // for a list of all the KmlCamera members see:
                // http://code.google.com/apis/earth/documentation/reference/interface_kml_camera.html

                // update the view
                m_ge.getView().setAbstractView(camera);
            }
        }