How to specify Latitude and Longtitude

Topics: Customizing Orchard
Apr 29, 2012 at 7:55 PM

I was looking at the video for adding Bing.Maps. After installing i tried to make a Bing Map widget, but when i added the Latitude as 51.467 and the Longtitude as 5.250 I got an errormessage stating that the values were not correct.  I tried different ways, but no succes.

Could anyone give some input?

Apr 29, 2012 at 8:04 PM
Edited Jun 1, 2012 at 10:57 AM

Filling Latitude with 51.467 and Longtitude with: 5.250

When I do a save then I get the following error messages :
The Value '51.467' is not valid for Latitude
The Value '5.250' is not a valid for Longtitude

If I keep it to 51 and 5 then the save is correct and I get my map

I even did a complete new install and tried the Bing.map first, but the same result.

Any clue what is happening?

 

Jun 1, 2012 at 7:10 PM
Edited Jun 2, 2012 at 11:26 AM

I'm LOST. I thought it was fixed by using commas inside the specifications, while I did not get an error message like before. But after i wrote this post I checked the output.... and there was no picture at all.

I think that it has to do with LOCALIZATION, since I do use the language NL.
Or is it because I use Windows 7 Dutch?

Nice module anyway, if you keep it at 51 and 5 and not more accurate.

I do not know what to do more and I hope somebody can give directions.

Thanks in advance.

Jun 4, 2012 at 7:11 PM

Is nobody able/willing to reply?

Developer
Jun 4, 2012 at 7:14 PM

Does it work when you set the site's culture to en-US? If so, you probably could fix the Bing module to parse the input using a invariant culture.

Jun 4, 2012 at 7:24 PM

I did build a new site and thirectly after this i've tried to add bing.maps.

The site's culture is standard on en-US. I did not add an other culture.

It must have to do with the fact that i use Windows 7 Dutch language.

I have to use comma's inside the Latitude and Lontitude, otherwise i will get error messages.

 

I tried to do some debugging, but i do not know whether i did this correct, but then i got a screen telling me:

Locating source for 'C:\Users\sebros\My Projects\Clay\src\ClaySharp\Clay.cs'. Checksum: MD5 {7f 5c 90 ed 45 90 49 c1 3a 92 8e 97 ff 0 f9 fc}

The file 'C:\Users\sebros\My Projects\Clay\src\ClaySharp\Clay.cs' does not exist.

Could this have to do with it? and if yes, what does it mean

Coordinator
Jun 4, 2012 at 7:30 PM

I THINK THERE IS A BUG IN THIS MODULE !

To be more precise, based on the symptoms, the module must be using Int32.Parse() directly to get the longitude and latitude. On your system it will use NL locale, which will only work if you use comas, and then again when serializing the values in the HTML output, but Bing won't recognize them because it expects '.', as I can fairly assume.

The solution is to fix the module, by forcing to use a neutral culture during parsing AND rendering. Or even better using the current culture information of the site, so you can change it, and use the neutral on persisting the value in HTML. It's done like this for all DateTime entry.

Create a fork of the module, fix it, then submit a fork to the author. 

Coordinator
Jun 4, 2012 at 7:32 PM

My bad, I should have written:

PLEASE create a fork of the module, fix it, then submit a fork to the author. 

and also 

THANK YOU

and maybe by the way

YOU ARE WELCOME !

Jun 4, 2012 at 7:39 PM

I did not change nor add a new culture, it is still only en-US, so I also think it's a Bug.

But although I'm willing, I do not understand your last sentense about create a fork and do not know what to do to submit it.

 

Coordinator
Jun 4, 2012 at 7:41 PM

... "The solution is to fix the module, by forcing to use a neutral culture during parsing AND rendering." ...

You need to change the failing code by yourself or ask the module's author to do it if you can't. A "fork" in mercurial, is a copy of the source code that you can change. It also allows you to submit the changes to the author so he can copy them to the main source code "branch".

Jun 4, 2012 at 7:52 PM
sebastienros wrote:

... "The solution is to fix the module, by forcing to use a neutral culture during parsing AND rendering." ...

You need to change the failing code by yourself or ask the module's author to do it if you can't. A "fork" in mercurial, is a copy of the source code that you can change. It also allows you to submit the changes to the author so he can copy them to the main source code "branch".


I'm learning an awfull lot and I love to work on it in an area that is complete new to me. 

I do not know which source code I should look at and work on. Can you give a clue?

I also will try to contact the modules author about this.

Coordinator
Jun 4, 2012 at 8:10 PM

Quick and dirty solution:

Open  Modules/Bing.Maps/Views/BingMap.cshtml

On line 11 replace by 

var latlong = new VELatLong(@Model.Latitude.ToString(System.Globalization.CultureInfo.InvariantCulture), @Model.Longitude.ToString(System.Globalization.CultureInfo.InvariantCulture));

This should work when you enter values using comas.

Jun 4, 2012 at 8:20 PM
Edited Jun 4, 2012 at 8:25 PM

Whoh, that's quick, thanks Sebastien !

I will change the coding like you have pointed out.

 The place where you fnd the module is

 Modules/Bing.Maps/Views/Parts/BingMap.cshtml

AND IT WORKS LIKE A CHARM :-)

Thanks again