コード例 #1
0
        private void setLocCI_Click(object sender, EventArgs e)
        {
            pt = new Point();
            pt = pictureBox1.PointToClient(p);
            gu = new Mapping.GeoUtils();
            mu = new Mapping.MapUtils();

            //translate pixels tapped on to GPS coordinates
            double lat    = currCentre.getLat();
            double lng    = currCentre.getLng();
            double newLat = Mapping.CoordTranslate.adjustLatByPixels(lat, pt.Y - 150, zoom);
            double newLng = Mapping.CoordTranslate.adjustLonByPixels(lng, pt.X - 240, zoom);

            //clear previous markers from the array
            currMap.clearMarkers();

            //add the new loc marker to the map
            currMarker = new Mapping.Marker(1, "red", "S", (newLat + "," + newLng));
            currMap.setMarkers(currMarker.toString());

            //check if need to add existing destination marker
            if (destLoc.getReady() == 1)
            {
                currMarker = new Mapping.Marker(1, "yellow", "D", destLoc.getCoords());
                currMap.setMarkers(currMarker.toString());
            }

            //generate map
            currMap.setCenter((newLat + "," + newLng));
            pictureBox1.Image = mu.getMapImage(mu.generateMap(currMap));
            pictureBox1.Refresh();

            //update start location object
            startLoc.setLat(newLat);
            startLoc.setLng(newLng);
            startLoc.setCoords((newLat + "," + newLng));
            startLoc.setReady(1);

            //update centre location
            currCentre.setLat(newLat);
            currCentre.setLng(newLng);
            currCentre.setCoords((newLat + "," + newLng));

            //update address to textbox
            Mapping.Geo tempG = new Mapping.Geo();
            tempG.setLat(newLat);
            tempG.setLatLng((newLat + "," + newLng));
            Mapping.Location tempLoc = gu.getGeoLocation(tempG);
            tbLoc.Text = tempLoc.getDisplay_address();
        }