How to Use Xamarin.Forms and GoogleMaps/GeoLocation - google-maps

I am writing a Xamarin.Forms PCL app, to support iOS and Android OS for my app.
In the root project, I have a view containing a ViewList and a map (from Xamarin.Forms.Maps).
I learnt I have to use CustomRenderer for each platform to add customized behavior. What I am trying to achieve to add a LocationManager/GeoLocation to identify the users position via GPS and show his position with a pin/marker. Additionally to that, I get positions from the root project of several persons which pins must also be shown within the map.
Should I have to use an interface exporting functionality or use an appropriate custom map renderer?
I have no idea to achieve that, the examples at the Xamarin.Forms website and research within Stackoverflow do not give a hint.
Here is some code I have so far (extract):
using System;
using Awesome;
using Xamarin.Forms;
using Xamarin.Forms.Maps;
using System.Collections.ObjectModel;
using System.Collections.Generic;
using Plugin.Geolocator;
using System.Threading.Tasks;
namespace KiLa
{
public class KidsFinder : ContentPage, ITabPage
{
public string TabIcon => FontAwesome.FAMapMarker;
public string SelectedTabIcon => FontAwesome.FAMapMarker;
private Boolean _showKidsList;
private ListView _listView;
public ObservableCollection<KidsViewModel> kidsList = new ObservableCollection<KidsViewModel>();
public KidsFinder ()
{
Title = "KidsFinder";
// Define listView
// Any near/identified kids? Mockup
// TODO: get real data
Boolean kidsPresent = true;
// Initial height of map
double mapHeight = 300.0;
// coordinates of Beuth Hochschule, Haus Gauss
double latitude = 52.543100;
double longitude = 13.351450;
// Show/hide kidsList (listView)
//Boolean showKidsList = false;
_showKidsList = false;
// Define toggleButton
Button toggleButton = new Button();
toggleButton.Text = "Verstecke Liste";
toggleButton.Clicked += new EventHandler(OnClickEvent);
if(kidsPresent == true)
{
toggleButton.IsVisible = true;
mapHeight = 200.0;
_showKidsList = true;
} else
{
toggleButton.IsVisible = false;
mapHeight = 300.0;
_showKidsList = false;
}
// Mockup some kids
Position pos1 = new Position(latitude + 0.002, longitude + 0.002);
Position pos2 = new Position (latitude - 0.002, longitude - 0.002);
kidsList.Add(new KidsViewModel{Name="Tim", ActualPositon=pos1, DistanceToEducator=5.4});
kidsList.Add(new KidsViewModel{Name="Sabine", ActualPositon=pos2, DistanceToEducator=20.4});
_listView = new ListView();
_listView.ItemsSource = kidsList;
//listView.VerticalOptions = LayoutOptions.FillAndExpand;
_listView.ItemTemplate = new DataTemplate (typeof(KidsCustomCell));
_listView.RowHeight = 50;
if (_showKidsList == false) {
_listView.IsVisible = false;
} else {
_listView.IsVisible = true;
}
// Define mapView
var kidsMap = new KidsMap ();
kidsMap.MapType = MapType.Street;
kidsMap.WidthRequest = 960;
kidsMap.HeightRequest = mapHeight;
kidsMap.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(latitude,longitude), Distance.FromMiles(0.3)));
// Set label of pins with kids names,
foreach (KidsViewModel kvm in kidsList) {
Pin pin = new Pin() {
Label = kvm.Name,
Position = kvm.ActualPositon
};
kidsMap.Pins.Add(pin);
}

You should use GetLocation and declare the permissions necessary to use the LocationServices
[assembly: UsesPermission(Manifest.Permission.AccessFineLocation)]
[assembly: UsesPermission(Manifest.Permission.AccessCoarseLocation)]
This is not strictly necessary for obtaining the GPS coordinates of the device, but this example will attempt to provide a street address for the current location:
[assembly: UsesPermission(Manifest.Permission.Internet)]
Add a method called InitializeLocationManager to activity
void InitializeLocationManager()
{
_locationManager = (LocationManager) GetSystemService(LocationService);
Criteria criteriaForLocationService = new Criteria
{
Accuracy = Accuracy.Fine
};
IList<string> acceptableLocationProviders = _locationManager.GetProviders(criteriaForLocationService, true);
if (acceptableLocationProviders.Any())
{
_locationProvider = acceptableLocationProviders.First();
}
else
{
_locationProvider = string.Empty;
}
Log.Debug(TAG, "Using " + _locationProvider + ".");
}
The LocationManager class will listen for GPS updates from the device and notify the application by way of events. In this example we ask Android for the best location provider that matches a given set of Criteria and provide that provider to LocationManager.
For more details how to get current location using Xamarin Forms, follow this link: https://developer.xamarin.com/recipes/android/os_device_resources/gps/get_current_device_location/

Related

Can't load a service for category "ExternalGraphicFactory"

I'm using geotools-18.5, with JavaFx in Inteliji IDE.
When I want to create PointSymbolizer from a svg or png image.
StyleBuilder builder = new StyleBuilder();
ExternalGraphic extGraphic = builder.createExternalGraphic("file:/home/cuongnv/test.svg", "svg");
I build code OK, but when run, I received warning:
WARNING: Can't load a service for category "ExternalGraphicFactory".
Provider org.geotools.renderer.style.ImageGraphicFactory could not be
instantiated.
Can someone help me ?
Here is full code:
private Style createStyleBuilder(){
StyleBuilder builder = new StyleBuilder();
FilterFactory2 ff = builder.getFilterFactory();
// RULE 1
// first rule to draw cities
// define a point symbolizer representing a city
Graphic city = builder.createGraphic();
city.setSize(ff.literal(50));
ExternalGraphic extGraphic = builder.createExternalGraphic("file:/home/cuongnv/Javafx/GeoTool/geotools_fx_tutorial-master/geotools-fx/src/main/resources/images/console.svg", "svg"); // svg
city.addExternalGraphic(extGraphic);
PointSymbolizer pointSymbolizer = builder.createPointSymbolizer(city);
Rule rule1 = builder.createRule(pointSymbolizer);
rule1.setName("rule1");
rule1.getDescription().setTitle("City");
rule1.getDescription().setAbstract("Rule for drawing cities");
Rule rules[] = new Rule[] {rule1};
FeatureTypeStyle featureTypeStyle = builder.createFeatureTypeStyle("Feature", rules);
Style style = builder.createStyle();
style.setName("style");
style.getDescription().setTitle("User Style");
style.getDescription().setAbstract("Definition of Style");
style.featureTypeStyles().add(featureTypeStyle);
return style;
}
TYPE = DataUtilities.createType(
"Dataset",
"geometry:Geometry:srid=4326"
+ ","
+ "name:String,"
+ "id:String"
);
SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(TYPE);
GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory();
com.vividsolutions.jts.geom.Point point = geometryFactory.createPoint(new Coordinate(x,y));
featureBuilder.add(point);
SimpleFeature feature = featureBuilder.buildFeature(null);
DefaultFeatureCollection featureCollection = new DefaultFeatureCollection("internal", TYPE);
featureCollection.add(feature);
Style style = createStyleBuilder();
Layer layer = new FeatureLayer(featureCollection, style);
layer.setTitle("New Point");
mapContent.layers().add(layer);
You have set the image mime type incorrectly, it should be:
ExternalGraphic extGraphic = builder.createExternalGraphic("file:/stuff/ian/geoserver/data/styles/burg02.svg", "image/svg"); // svg
and all will work.
EDIT
If you are still having issues then try adding this code to the end of the createStyle module and look at the generated SVG, possibly in GeoServer to test it out.
SLDTransformer styleTransform = new SLDTransformer();
StyledLayerDescriptor sld = sf.createStyledLayerDescriptor();
UserLayer layer = sf.createUserLayer();
layer.setLayerFeatureConstraints(new FeatureTypeConstraint[] {null});
sld.addStyledLayer(layer);
layer.addUserStyle(style);
try {
String xml = styleTransform.transform(sld);
System.out.println(xml);
} catch (TransformerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

How to get a Flag property from email message?

Can I somehow get a Flag property from EmailMessage or Item object? There is no getFlag() method, I also didn't find it in item.getPropertyBag(). I'm using ews-java-api-2.0. flag setting on outlook web app
There is a strongly type flag property in EWS in 2013 and greater so you could modify the EWS Java source to cater for that. Otherwise if you use the underlying Extended properties you can get the same information eg
ExtendedPropertyDefinition PR_FLAG_STATUS = new ExtendedPropertyDefinition(0x1090, MapiPropertyType.Integer);
ExtendedPropertyDefinition FlagRequest = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.Common, 0x8530, MapiPropertyType.String);
PropertySet fiFindItemPropset = new PropertySet(BasePropertySet.FirstClassProperties);
fiFindItemPropset.Add(FlagRequest);
fiFindItemPropset.Add(PR_FLAG_STATUS);
FolderId FolderToAccess = new FolderId(WellKnownFolderName.Inbox, MailboxToAccess);
ItemView ivItemView = new ItemView(1000);
ivItemView.PropertySet = fiFindItemPropset;
FindItemsResults<Item> FindItemResults = null;
do
{
FindItemResults = service.FindItems(FolderToAccess, ivItemView);
foreach (Item itItem in FindItemResults.Items)
{
Console.WriteLine(itItem.Subject);
Object FlagValue = null;
if (itItem.TryGetProperty(FlagRequest, out FlagValue))
{
Console.WriteLine("Flag : " + FlagValue);
}
Object PR_FLAG_STATUS_Value = null;
if (itItem.TryGetProperty(PR_FLAG_STATUS, out PR_FLAG_STATUS_Value))
{
Console.WriteLine("PR_FLAG_STATUS : " + PR_FLAG_STATUS_Value);
}
}
ivItemView.Offset += FindItemResults.Items.Count;
} while (FindItemResults.MoreAvailable);
Theres a full list of flag properties https://msdn.microsoft.com/en-us/library/ee201258(v=exchg.80).aspx

Xamarin free HTML or DOC to PDF Conversion

I'm currently searching for a library or a way to convert HTML OR DOCX files into PDF on the phone/tab, primarily I'am searching for a way on Android or iOS idk if its a PCL or platform specific approach. I could do this for every Platform independently, because our app requires iOS 8 or android kitkat, both supporting native PDF conversion but i want to do it seamless for the user, so the question is, if anyone has done this before, without loading it into a visible Webview at first or has knowledge of an open not GPL licensed API(can't publish the code), to do this with Xamarin.
I am aware of the possibility to do this online, but I don't want to to be dependent to a online service for this.
Help and ideas are appreciated.
Android Solution:
Call the SafeHTMLToPDF(string html, string filename) via a dependency service like
DependencyService.Get<YOURINTERFACE>().SafeHTMLToPDF(htmlString, "Invoice");
public string SafeHTMLToPDF(string html, string filename)
{
var dir = new Java.IO.File(Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + "/pay&go/");
var file = new Java.IO.File(dir + "/" + filename + ".pdf");
if (!dir.Exists())
dir.Mkdirs();
int x = 0;
while (file.Exists())
{
x++;
file= new Java.IO.File(dir + "/" + filename + "( " + x + " )" + ".pdf");
}
if (webpage == null)
webpage = new Android.Webkit.WebView(GetApplicationContext());
int width = 2102;
int height = 2973;
webpage.Layout(0, 0, width, height);
webpage.LoadDataWithBaseURL("",html, "text/html", "UTF-8" , null);
webpage.SetWebViewClient(new WebViewCallBack(file.ToString()));
return file.ToString();
}
class WebViewCallBack : WebViewClient
{
string fileNameWithPath = null;
public WebViewCallBack(string path)
{
this.fileNameWithPath = path;
}
public override void OnPageFinished(Android.Webkit.WebView myWebview, string url)
{
PdfDocument document = new PdfDocument();
PdfDocument.Page page = document.StartPage(new PdfDocument.PageInfo.Builder(2120 ,3000, 1).Create());
myWebview.Draw(page.Canvas);
document.FinishPage(page);
Stream filestream = new MemoryStream();
FileOutputStream fos = new Java.IO.FileOutputStream(fileNameWithPath, false); ;
try
{
document.WriteTo(filestream);
fos.Write(((MemoryStream)filestream).ToArray(), 0, (int)filestream.Length);
fos.Close();
}
catch
{
}
}
}
And the Way to do it under iOS
public string SafeHTMLToPDF(string html, string filename)
{
UIWebView webView = new UIWebView(new CGRect(0, 0, 6.5 * 72, 9 * 72));
var documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
var file = Path.Combine(documents, "Invoice" + "_" + DateTime.Now.ToShortDateString() + "_" + DateTime.Now.ToShortTimeString() + ".pdf");
webView.Delegate = new WebViewCallBack(file);
webView.ScalesPageToFit = true;
webView.UserInteractionEnabled = false;
webView.BackgroundColor = UIColor.White;
webView.LoadHtmlString(html, null);
return file;
}
class WebViewCallBack : UIWebViewDelegate
{
string filename = null;
public WebViewCallBack(string path)
{
this.filename = path;
}
public override void LoadingFinished(UIWebView webView)
{
double height, width;
int header, sidespace;
width = 595.2;
height = 841.8;
header = 10;
sidespace = 10;
UIEdgeInsets pageMargins = new UIEdgeInsets(header, sidespace, header, sidespace);
webView.ViewPrintFormatter.ContentInsets = pageMargins;
UIPrintPageRenderer renderer = new UIPrintPageRenderer();
renderer.AddPrintFormatter(webView.ViewPrintFormatter, 0);
CGSize pageSize = new CGSize(width, height);
CGRect printableRect = new CGRect(sidespace,
header,
pageSize.Width - (sidespace * 2),
pageSize.Height - (header * 2));
CGRect paperRect = new CGRect(0, 0, width, height);
renderer.SetValueForKey(NSValue.FromObject(paperRect), (NSString)"paperRect");
renderer.SetValueForKey(NSValue.FromObject(printableRect), (NSString)"printableRect");
NSData file = PrintToPDFWithRenderer(renderer, paperRect);
File.WriteAllBytes(filename, file.ToArray());
}
private NSData PrintToPDFWithRenderer(UIPrintPageRenderer renderer, CGRect paperRect)
{
NSMutableData pdfData = new NSMutableData();
UIGraphics.BeginPDFContext(pdfData, paperRect, null);
renderer.PrepareForDrawingPages(new NSRange(0, renderer.NumberOfPages));
CGRect bounds = UIGraphics.PDFContextBounds;
for (int i = 0; i < renderer.NumberOfPages; i++)
{
UIGraphics.BeginPDFPage();
renderer.DrawPage(i, paperRect);
}
UIGraphics.EndPDFContent();
return pdfData;
}
}
Frustrated with the existing solutions, I've built some extension methods (OpenSource, MIT Licensed) that convert HTML or the content of a Xamarin.Forms.WebView to a PDF file. Sample usage for WebView to PDF:
async void ShareButton_Clicked(object sender, EventArgs e)
{
if (Forms9Patch.ToPdfService.IsAvailable)
{
if (await webView.ToPdfAsync("output.pdf") is ToFileResult pdfResult)
{
if (pdfResult.IsError)
using (Toast.Create("PDF Failure", pdfResult.Result)) { }
else
{
var collection = new Forms9Patch.MimeItemCollection();
collection.AddBytesFromFile("application/pdf", pdfResult.Result);
Forms9Patch.Sharing.Share(collection, shareButton);
}
}
}
else
using (Toast.Create(null, "PDF Export is not available on this device")) { }
}
}
For a more complete explanation of how to use it, here's a short article: https://medium.com/#ben_12456/share-xamarin-forms-webview-as-a-pdf-a877542e824a?
You can able to convert the HTML to PDF file without any third party library. I am sharing my git repo for future reference.
https://github.com/dinesh4official/XFPDF
Yes, you can convert a Word document to PDF in Xamarin with a few lines of code easily. You need to refer Syncfusion.Xamarin.DocIORenderer from nuget.org
Assembly assembly = typeof(App).GetTypeInfo().Assembly;
// Retrieves the document stream from embedded Word document
Stream inputStream = assembly.GetManifestResourceStream("WordToPDF.Assets.GettingStarted.docx");
string fileName = "GettingStarted.pdf";
// Creates new instance of WordDocument
WordDocument wordDocument = new WordDocument(inputStream,Syncfusion.DocIO.FormatType.Automatic);
inputStream.Dispose();
// Creates new instance of DocIORenderer for Word to PDF conversion
DocIORenderer render = new DocIORenderer();
// Converts Word document into PDF document
PdfDocument pdfDocument = render.ConvertToPDF(wordDocument);
// Releases all resources used by the DocIORenderer and WordDocument instance
render.Dispose();
document.Close();
// Saves the converted PDF file
MemoryStream outputStream = new MemoryStream();
pdfDocument.Save(outputStream);
// Releases all resources used by the PdfDocument instance
pdfDocument.Close();
To know more about this, kindly refer here.

No pushpin when using MapsTask on WP8

I can't see the pushpin using MapsTask, the map is ok, but no pushpin on the map, anyone knows why? thank you!
if (geo != null)
{
MapsTask mapsTask = new MapsTask();
mapsTask.Center = geo;
mapsTask.ZoomLevel = 15;
mapsTask.Show();
}
you can use mapTask.SearchTerm, the first result will show on the map with the pushpin.
mapsTask has few APIs to do more works.
If you want multiple pushpins or customize for more info,use map control and design it in xaml and .cs file.
here is a good example:
http://www.geekchamp.com/articles/windows-phone-drawing-custom-pushpins-on-the-map-control-what-options-do-we-have
hopes it helps.
ReverseGeocodeQuery query = new ReverseGeocodeQuery();
query.GeoCoordinate = new GeoCoordinate(lat, longitude);
query.QueryCompleted += (s, e) =>
{
if (e.Error != null)
return;
searchTerm = e.Result[0].Information.Address.Street; // task.SearchTerm will contain the result of address
};
Now , you have the search Term , in MapsTask class, just assign
MapsTask task = new MapsTask();
task.SearchTerm = searchTerm;
This should work fine.

Google maps - how to get building's polygon coordinates from address?

How to implement the following:
User defines an address
User defines a color
Service searches for a corresponding building on the google map
Service fills the found building on the map with the color
I know how to:
1.find lat/long of the address
2.draw the polygon
So, to do the task I need to get polygon coordinates of building from address. How to?
(1) Acquire image tile
(2) Segment buildings based on pixel color (here, 0xF2EEE6).
(3) Image cleanup (e.g. erosion then dilation) + algorithm to acquire pixel coordinates of polygon corners.
(4) Mercator projection to acquire lat/long of pixel
You can convert the address to geographic coordinates by the use of the Google Geocoding API.
https://maps.googleapis.com/maps/api/geocode/json?address=SOME_ADDRESS&key=YOUR_API_KEY
Then, you can use Python and a styled static map to obtain the polygon of the building (in pixel coordinates) at some location:
import numpy as np
from requests.utils import quote
from skimage.measure import find_contours, points_in_poly, approximate_polygon
from skimage import io
from skimage import color
from threading import Thread
center_latitude = None ##put latitude here
center_longitude = None ##put longitude here
mapZoom = str(20)
midX = 300
midY = 300
# Styled google maps url showing only the buildings
safeURL_Style = quote('feature:landscape.man_made|element:geometry.stroke|visibility:on|color:0xffffff|weight:1')
urlBuildings = "http://maps.googleapis.com/maps/api/staticmap?center=" + str_Center + "&zoom=" + mapZoom + "&format=png32&sensor=false&size=" + str_Size + "&maptype=roadmap&style=visibility:off&style=" + safeURL_Style
mainBuilding = None
imgBuildings = io.imread(urlBuildings)
gray_imgBuildings = color.rgb2gray(imgBuildings)
# will create inverted binary image
binary_imageBuildings = np.where(gray_imgBuildings > np.mean(gray_imgBuildings), 0.0, 1.0)
contoursBuildings = find_contours(binary_imageBuildings, 0.1)
for n, contourBuilding in enumerate(contoursBuildings):
if (contourBuilding[0, 1] == contourBuilding[-1, 1]) and (contourBuilding[0, 0] == contourBuilding[-1, 0]):
# check if it is inside any other polygon, so this will remove any additional elements
isInside = False
skipPoly = False
for othersPolygon in contoursBuildings:
isInside = points_in_poly(contourBuilding, othersPolygon)
if all(isInside):
skipPoly = True
break
if skipPoly == False:
center_inside = points_in_poly(np.array([[midX, midY]]), contourBuilding)
if center_inside:
# approximate will generalize the polygon
mainBuilding = approximate_polygon(contourBuilding, tolerance=2)
print(mainBuilding)
Now, you can convert the pixel coordinates to latitude and longitude by the use of little JavaScript, and the Google Maps API:
function point2LatLng(point, map) {
var topRight = map.getProjection().fromLatLngToPoint(map.getBounds().getNorthEast());
var bottomLeft = map.getProjection().fromLatLngToPoint(map.getBounds().getSouthWest());
var scale = Math.pow(2, map.getZoom());
var worldPoint = new google.maps.Point(point.x / scale + bottomLeft.x, point.y / scale + topRight.y);
return map.getProjection().fromPointToLatLng(worldPoint);
}
var convertedPointsMain = [];
for (var i = 0; i < pxlMainPolygons[p].length; i++) {
var conv_point = {
x: Math.round(pxlMainPolygons[p][i][1]),
y: Math.round(pxlMainPolygons[p][i][0])
};
convertedPointsMain[i] = point2LatLng(conv_point, map);
}
console.log(convertedPointsMain);
Might I humbly suggest you use OpenStreetMaps for this instead ?
It's a lot easier, because then you can use the OverPass API.
However, polygons might not match with google-maps or with state survey.
The latter also holds true if you would use google-maps.
// https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL
private static string GetOqlBuildingQuery(int distance, decimal latitude, decimal longitude)
{
System.Globalization.NumberFormatInfo nfi = new System.Globalization.NumberFormatInfo()
{
NumberGroupSeparator = "",
NumberDecimalSeparator = ".",
CurrencyGroupSeparator = "",
CurrencyDecimalSeparator = ".",
CurrencySymbol = ""
};
// [out: json];
// way(around:25, 47.360867, 8.534703)["building"];
// out ids geom meta;
string oqlQuery = #"[out:json];
way(around:" + distance.ToString(nfi) + ", "
+ latitude.ToString(nfi) + ", " + longitude.ToString(nfi)
+ #")[""building""];
out ids geom;"; // ohne meta - ist minimal
return oqlQuery;
}
public static System.Collections.Generic.List<Wgs84Point> GetWgs84PolygonPoints(int distance, decimal latitude, decimal longitude)
{
string[] overpass_services = new string[] {
"http://overpass.osm.ch/api/interpreter",
"http://overpass.openstreetmap.fr/api/interpreter",
"http://overpass-api.de/api/interpreter",
"http://overpass.osm.rambler.ru/cgi/interpreter",
// "https://overpass.osm.vi-di.fr/api/interpreter", // offline...
};
// string url = "http://overpass.osm.ch/api/interpreter";
// string url = "http://overpass-api.de/api/interpreter";
string url = overpass_services[s_rnd.Next(0, overpass_services.Length)];
System.Collections.Specialized.NameValueCollection reqparm = new System.Collections.Specialized.NameValueCollection();
reqparm.Add("data", GetOqlBuildingQuery(distance, latitude, longitude));
string resp = PostRequest(url, reqparm);
// System.IO.File.WriteAllText(#"D:\username\Documents\visual studio 2017\Projects\TestPlotly\TestSpatial\testResponse.json", resp, System.Text.Encoding.UTF8);
// System.Console.WriteLine(resp);
// string resp = System.IO.File.ReadAllText(#"D:\username\Documents\visual studio 2017\Projects\TestPlotly\TestSpatial\testResponse.json", System.Text.Encoding.UTF8);
System.Collections.Generic.List<Wgs84Point> ls = null;
Overpass.Building.BuildingInfo ro = Overpass.Building.BuildingInfo.FromJson(resp);
if (ro != null && ro.Elements != null && ro.Elements.Count > 0 && ro.Elements[0].Geometry != null)
{
ls = new System.Collections.Generic.List<Wgs84Point>();
for (int i = 0; i < ro.Elements[0].Geometry.Count; ++i)
{
ls.Add(new Wgs84Point(ro.Elements[0].Geometry[i].Latitude, ro.Elements[0].Geometry[i].Longitude, i));
} // Next i
} // End if (ro != null && ro.Elements != null && ro.Elements.Count > 0 && ro.Elements[0].Geometry != null)
return ls;
} // End Function GetWgs84Points
I've been working on this for hours, the closest I have come is finding a request uri that returns a result with a polygon in it. I believe it specifies the building(boundary) by editids parameter. We just need a way to get the current editids from a building(boundary).
The URI I have is:
https://www.google.com/mapmaker?hl=en&gw=40&output=jsonp&ll=38.934911%2C-92.329359&spn=0.016288%2C0.056477&z=14&mpnum=0&vpid=1354239392511&editids=nAlkfrzSpBMuVg-hSJ&xauth=YOUR_XAUTH_HERE&geowiki_client=mapmaker&hl=en
Part of the result has what is needed:
"polygon":[{"gnew":{"loop":[{"vertex":[{"lat_e7":389364691,"lng_e7":-923341133},{"lat_e7":389362067,"lng_e7":-923342783},{"lat_e7":389361075,"lng_e7":-923343356},{"lat_e7":389360594,"lng_e7":-923342477},
I was intrigued on this problem and wrote a solution to it. See my github project.
The Google Maps API contains a GeocoderResults object that might be what you need. Specifically the data returned in the geometry field.