A couple of things i'd like to work out how to do and was wondering if anyone else had figured them out before i start:
1. At the moment the zoom level is hard-coded. It would be good if the map auto-zoomed to a level that included the furthest marker and no further. That way if you are only searching on say a 10 mile radius the map shows a street level view rather than the entire country,
Good idea. Thanks. One other things we've noticed is that in the UK Google do not have rights to use postcode data therefore the search results for a postcode can be out by over 100m of the user's actual location.
This will return the co-ordinates of the postcode accurately. Unfortunately from what i can tell, the locator package doesn't accept co-ordinates as a search term. Is this something that could be added?
What i've actually done is moving towards proper geo-coding for postcodes. It now takes a user postcode and uses the locator package to perform the search based on the users postcode. If it can geocode the postcode via the Google local search then it uses this result to place the pin on the map if not then the locator package places the pin on the map. Therefore the user will see their address geo-coded accurately even though the search is actually performed on Google's slightly innaccurate information - i'll post a link shortly when the site is live.
This passes in the postcode. If it can be geo-coded the pin is placed, if not it defaults to the 2nd parameter which is the co-ordinates returned from the standard Google search.
As i siad before this is a hack of sorts as the actual search is still done on the incorrect co-ordinates but presumably the entire locator package could use the Google Local Search as well as the standard method?
Hey Rich - Any code is useful is you want to share it, I have got something working in a different .NET using the yahoo API too - But I have integrated this project into a site and customised it quite heavily so starting again would be :(
I have used Dan's idea of using Tom's tutorial for the front end and it puts the markers almost smack bang perfect - The problem still is
Making the DataType in the backend use the same 'hack' as the front end
The mileage, the map is right but the mileage in the results is way out (Some over 3 miles)
If anyone knows Dan Evans above, could they send him a link to this post - As I'd like to know how he got round the mileage problem on that full circle site? And did he change the DataType for the customer?
What about the miles (Distance away) you return in the results? Is that still powered by this normal Google API, as at the minute I'm having a problem with the a marker being right next to another but the result text below saying its 3 miles away?
Hey Tim - Where abouts are the DataTypes stored in Umbraco? I want to see if I can add this 'hack' to the datatype so the places added are a lot more accurate without having to move the pin manually :(
Basicly a very simple datatype, basicly just using this custom control: http://www.codeplex.com/googlemap, not sure if there is a newer version that has more accurate uk postcode placement
It shows it as 2 miles away on the text? When in fact its the same place on the map (Or more or less) - I was just wondering how to get round this? This doesn't happen on all postcodes, just random ones :S
If I remember rightly from the project we did the google code only worked on the first part(s) of the Post code, therefore it wasn't that accurate, I maybe wrong however, brains a little fuzzy.
It's coming back to me now but not sure it's going to help you. Our solution was javascript and we used Googles 'localSearch' call to find the postcode geo location
We then displayed relevant branches around this postcode using the google api but we already had geo location for them.
There's a difference as well in distance 'as the crow flies' and 'driving distance' but google worked this out (again not sure if relevant).
I guess some postcode data is less accurate than others. I'm in London so postcodes change frequently across a small area. If you search in a rural area then this will become more inaccurate.
I know no one is probably interested, but I near pissed my pants a second ago as I have actually managed to edit the source and got the package working on UK postcodes - And its accurate up to a few metres!!
Both the DataType for the UI and also the results (Including how many miles away) - Once I triple check everything I'll post up the DLL
Its jimmysmithjnr - But I'd prefer you to look at them first before I do anything, especially as I haven't got a clue how codeplex works :P I'll get them sent over
I'll get them sent over in the morning, I'm still tweaking the usercontrol results and double checking everything is fine - What's your email and I'll email you some info ;)
Going to go to bed now, all this excitement is a bit too much .. lol
How to customise the zoom level
Tim,
This package is great - good work.
A couple of things i'd like to work out how to do and was wondering if anyone else had figured them out before i start:
1. At the moment the zoom level is hard-coded. It would be good if the map auto-zoomed to a level that included the furthest marker and no further. That way if you are only searching on say a 10 mile radius the map shows a street level view rather than the entire country,
2. Make is so each red marker has a letter on it indicating which "store" it refers to, then list the stores by letter. Like this sort of search: http://maps.google.co.uk/maps?f=q&source=s_q&hl=en&geocode=&q=oval&sll=53.800651,-4.064941&sspn=18.336241,57.084961&ie=UTF8&z=6
Thanks
Dan
Hi Dan,
You could make the zoom level dynamic by doing:
before the loop where it add the markers:
var bounds = new GLatLngBounds();
in the loop where it adds the markers
bounds.extend(latlng<xsl:value-of select="@id"/>);
after the loop
map.setZoom(map.getBoundsZoomLevel(bounds)-1);
Good idea. Thanks. One other things we've noticed is that in the UK Google do not have rights to use postcode data therefore the search results for a postcode can be out by over 100m of the user's actual location.
There is a way around this by doing a local search which oodly Google can geo-code a postcode - see http://www.tomanthony.co.uk/blog/geocoding-uk-postcodes-with-google-map-api/ for details.
This will return the co-ordinates of the postcode accurately. Unfortunately from what i can tell, the locator package doesn't accept co-ordinates as a search term. Is this something that could be added?
Thanks
Dan
Sure you could add that, sourcecode is available here: http://locator4umbraco.codeplex.com/
What i've actually done is moving towards proper geo-coding for postcodes. It now takes a user postcode and uses the locator package to perform the search based on the users postcode. If it can geocode the postcode via the Google local search then it uses this result to place the pin on the map if not then the locator package places the pin on the map. Therefore the user will see their address geo-coded accurately even though the search is actually performed on Google's slightly innaccurate information - i'll post a link shortly when the site is live.
Great, would love to see that!
This is the version of Tim's locator package that places the pin on the map based on actual geo-coding of the postcode:
http://www.fullcircleuk.com/store-finder?GCoords=&s=e2+7pr+UK&gender=both&x=34&y=4
If you compare the pin location with where the standard Google search places it you'll see there is a big difference http://lab.nibble.be/shops.aspx?s=e2+7pr+uk&radius=0
The key function call is:
This passes in the postcode. If it can be geo-coded the pin is placed, if not it defaults to the 2nd parameter which is the co-ordinates returned from the standard Google search.
More info on how/why it works like this here - http://www.tomanthony.co.uk/blog/geocoding-uk-postcodes-with-google-map-api/
As i siad before this is a hack of sorts as the actual search is still done on the incorrect co-ordinates but presumably the entire locator package could use the Google Local Search as well as the standard method?
@Dan, thanks for showing. Yeah the sourcecode should be updated to make sure UK postcodes are properly geocoded.
I see on submit of the search you add UK, you can also do this with one of the parameters on the locator (AddressExtra).
Like: AddressExtra=", UK" if you only want to search from UK locations
Was the source ever updated for the UK postcodes Tim? As the version I'm using the postcodes are quite a bit out?
I've sorted UK postcodes for another project as the UK google postcodes were out.
We used another free service, I can dig out the code if you like?
Not an Umbraco project, just .NET but shouldn't be a problem.
My solution uses client side JS to geo code the postcode using Google local search which does provide accuracy:
http://www.fullcircleuk.com/store-finder?s=W1A1EX+UK&gender=both&x=40&y=1&flagship=1
JS:
Hey Rich - Any code is useful is you want to share it, I have got something working in a different .NET using the yahoo API too - But I have integrated this project into a site and customised it quite heavily so starting again would be :(
I have used Dan's idea of using Tom's tutorial for the front end and it puts the markers almost smack bang perfect - The problem still is
Hey Dan
What about the miles (Distance away) you return in the results? Is that still powered by this normal Google API, as at the minute I'm having a problem with the a marker being right next to another but the result text below saying its 3 miles away?
@Lee the distance is calculated by some c#, so you'll need to mod the sourcecode or get/display the distance an other way.
Uk Postcode data is said to be free soon: http://news.bbc.co.uk/2/hi/technology/8402327.stm ; So if google then uses that data no hacks will be needed.
Hey Tim - Where abouts are the DataTypes stored in Umbraco? I want to see if I can add this 'hack' to the datatype so the places added are a lot more accurate without having to move the pin manually :(
Basicly a very simple datatype, basicly just using this custom control: http://www.codeplex.com/googlemap, not sure if there is a newer version that has more accurate uk postcode placement
The distance is calculated by Tim's code however the normal search is never more than 100m out so it should not effect things that much?
Hi Dan - Thanks for replying, but if you put in a postcode for one of the shops say CB3 0AF and search
http://www.fullcircleuk.com/store-finder?GCoords=&s=CB3+0AF+UK&gender=both
It shows it as 2 miles away on the text? When in fact its the same place on the map (Or more or less) - I was just wondering how to get round this? This doesn't happen on all postcodes, just random ones :S
18 Magdalene Street, CAMBRIDGE, Cambridgeshire, CB3 0AF
01223 353 800
Womenswear 2 miles
If I remember rightly from the project we did the google code only worked on the first part(s) of the Post code, therefore it wasn't that accurate, I maybe wrong however, brains a little fuzzy.
I'll have a dig around the code we wrote.
R
Hi Lee,
It's coming back to me now but not sure it's going to help you. Our solution was javascript and we used Googles 'localSearch' call to find the postcode geo location
We then displayed relevant branches around this postcode using the google api but we already had geo location for them.
There's a difference as well in distance 'as the crow flies' and 'driving distance' but google worked this out (again not sure if relevant).
R
Where are you getting the lng and lat for your shops from?
I guess some postcode data is less accurate than others. I'm in London so postcodes change frequently across a small area. If you search in a rural area then this will become more inaccurate.
I've not installed this package but I assume that the 'search postcode' and the 'branch postcode' look up use the same process to return the long/lat.
Therefore even if the postcode is 'out' the 2 pins on the map should still be in exactly the same place?
Well after a few hours messing around, I have an almost spot on accurate postcode geocode from Google directly with C# only :)
Just going to see if I can change Tim's package to use this new way and we are in business
I know no one is probably interested, but I near pissed my pants a second ago as I have actually managed to edit the source and got the package working on UK postcodes - And its accurate up to a few metres!!
Both the DataType for the UI and also the results (Including how many miles away) - Once I triple check everything I'll post up the DLL
@Lee, awesome ! Would love to see the changes to I can get them added and update the package.
Do you want me to try and add them via codeplex Tim?
@Lee sure, what's your codeplex username ? I'll add you as a developer on the project then you can commit your changes.
Holy crap..
Its jimmysmithjnr - But I'd prefer you to look at them first before I do anything, especially as I haven't got a clue how codeplex works :P I'll get them sent over
Sure Lee that's perfect ! Got somewhere we can test the changes ?
Cheers,
Tim
I'll get them sent over in the morning, I'm still tweaking the usercontrol results and double checking everything is fine - What's your email and I'll email you some info ;)
Going to go to bed now, all this excitement is a bit too much .. lol
sweet, you can send them to tg(at)umbraco(dot)dk
Just so you all know I have sent it over to Tim now to look over :)
Hey Tim,
Is there any update on when the package might get updated with Lee's changes?
TIA,
David
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.