简体   繁体   中英

Create Lat+Long from a string?

In Windows Phone (mango) I am using Microsoft.Phone.Controls.Maps.

I currently have:

var _City = "Denver";
var _State = "Colorado";

And I want a pushpin:

var _Pushpin = new Pushpin();
_Pushpin.Location = new GeoCoordinate();
map1.Children.Add(_Pushpin);
map1.Center = _Pushpin.Location;

How can I create the correct GeoCoordinate from the strings alone?

Update with solution (using Bing): http://blog.jerrynixon.com/2011/10/bing-maps-geocoding.html

在此处输入图片说明

There are a couple of ways...

1) Get a Bing Maps API key and call into their web services to get the coordinates. ( see here for an example )
2) Have a local database of cities / states / coordinates to look up against. This is probably the preferred option if the app must run offline, although in that case you wouldn't see the maps anyway.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM