Ahmed Adly Ali


dear all

i need to get the user click country, imean when the user click on a certain point on the map (a certain level of zoom i can assure) ..

i ve tried the following:

var map = null;

var latLong = null;

var zoomLevel = 1;

function GetMap()

{

map = new VEMap('myMap');

map.LoadMap(new VELatLong(1, -1), 1 ,'r' ,false);

map.SetZoomLevel(zoomLevel);

map.AttachEvent('onclick', onMapClick);

latLong = map.GetCenter();

}

function onMapClick(e)

{

var x = e.mapX;

var y = e.mapY;

pixel = new VEPixel(x, y);

latLong = map.PixelToLatLong(pixel);

if(zoomLevel<3)

{

zoomLevel++;

SetCenterAndZoom();

}else{

//here i need to know which country did the user choose ...

}

}

function SetCenterAndZoom()

{

map.SetCenterAndZoom(latLong, zoomLevel);

}

so, any suggestions

Regards




Re: how to get the user click location

Derrick


VE is able to convert an address into a location, but at the moment, it is unable to convert a location (e.g lat long) into an address. So this scenerio is not possible at the moment. However, msw does offer this service.




Re: how to get the user click location

Ahmed

thank you Derrick for ur response, but what is "msw"




Re: how to get the user click location

SoulSolutions

MapPoint Web Service.

The technology is called reverse geocoding, plenty of posts here. MWS is a great solution but costs money, for just countries you should do a web search for free services that support reverse geocoding.

John.






Re: how to get the user click location

Derek Chan

Your looking at GetLocationInfo() method available through MWS which does the reverse geocoding your looking for.

More information about that here:
http://msdn2.microsoft.com/en-us/library/aa492585.aspx

As this is becoming a MWS rather than Virtual Earth topic, please bring your MWS questions over to the newsgroups at:
http://msdn.microsoft.com/newsgroups/default.aspx dg=microsoft.public.mappoint.webservice&lang=en&cr=US




Re: how to get the user click location

Mo Majad

there is another way

  1. get free data of all large cities and corresponding countries with Lat Long values from lets say http://www.geonames.org/export/
  2. import into your database
  3. when user clicks, query this database for nearest place passing in Lat Long and doing the radius sql calc
  4. Thats your user click location by nearest city

hope this helps

regards

Mo





Re: how to get the user click location

SoulSolutions

Hey Mo that would make an awesome article for www.viavirtualearth.com

Let me know if you're interested.

John.






Re: how to get the user click location

Mo Majad

Hi John, I am currently developing a website that uses such a functionality [user right clicks on map and nearest city is shown on ajax modal window form input] once done [in the next few weeks] I can write up an article with live example of website. Please let me know how to let you know. but basically this is the main bits:

1- Users pans / zoom to area they are interested in on Virtual Earth

2- They right click which shows menu to add information

3- The right click sends information to ajax web service to retrive nearest 3 cities from geonames database

4- This information is pre-populated in ajax modal window form input for user to fill in other details.

The website is a visual travel blog using Virtual Earth, where users can post and view travel blogs on map.

regards

Mo





Re: how to get the user click location

SoulSolutions

That would be awesome Mo. I'm sure just the stripped down basics of how to do it would be invaluable to many people.

Send me an email - john at soulsolutions.com.au

I can give you the basic html template that the current articles use.

We are building a big update for the site that will make the process easier but for now you do have to tinker with a html template.

John.