コード例 #1
0
        private void centerMap(Geocoder.Location location)
        {
            mapCenter = location;
            var lat = mapCenter.Latitude;
            var lon = mapCenter.Longitude;

            gMap.Position = new GMap.NET.PointLatLng(lat, lon);
        }
コード例 #2
0
        private void markCurrentLocation(Geocoder.Location location)
        {
            var lat = location.Latitude;
            var lon = location.Longitude;

            GMap.NET.WindowsForms.Markers.GMapMarkerGoogleGreen m = new GMap.NET.WindowsForms.Markers.GMapMarkerGoogleGreen(new GMap.NET.PointLatLng(lat, lon));
            currentPosition = m;
            markerOverlay.Markers.Add(m);
            m.ToolTipText = "Current Position";
        }
コード例 #3
0
        public Location GeocodeLocation(string address)
        {
            var url = "http://maps.googleapis.com/maps/api/geocode/xml?sensor=false&address=" + System.Web.HttpUtility.UrlEncode(address);

              var xmlString = _client.DownloadString(url);
              var xmlDoc = new System.Xml.XmlDocument();
              xmlDoc.LoadXml(xmlString);

              var loc = new Location();
              loc.Latitude = Double.Parse(xmlDoc.SelectSingleNode("//geometry/location/lat").InnerText, NumberFormatInfo.InvariantInfo);
              loc.Longitude = double.Parse(xmlDoc.SelectSingleNode("//geometry/location/lng").InnerText, NumberFormatInfo.InvariantInfo);

              return loc;
        }