Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Dan Evans 616 posts 988 karma points
    Aug 12, 2009 @ 12:00
    Dan Evans
    2

    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

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Sep 07, 2009 @ 10:50
    Tim Geyssens
    1

    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);

     

  • Dan Evans 616 posts 988 karma points
    Sep 08, 2009 @ 15:18
    Dan Evans
    0

    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

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Sep 09, 2009 @ 09:57
    Tim Geyssens
    0

    Sure you could add that, sourcecode is available here: http://locator4umbraco.codeplex.com/

  • Dan Evans 616 posts 988 karma points
    Sep 10, 2009 @ 00:37
    Dan Evans
    0

    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.

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Sep 10, 2009 @ 09:50
    Tim Geyssens
    0

    Great, would love to see that!

  • Dan Evans 616 posts 988 karma points
    Sep 11, 2009 @ 09:50
    Dan Evans
    1

    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:

    usePointFromPostcode('e2 7pr UK','51.5287858,-0.0712012', placeMarkerAtPoint)

    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?

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Sep 11, 2009 @ 12:05
    Tim Geyssens
    0

    @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

  • Lee 1123 posts 3059 karma points
    Jan 14, 2010 @ 14:41
    Lee
    0

    Was the source ever updated for the UK postcodes Tim?  As the version I'm using the postcodes are quite a bit out?

  • Rich Green 2246 posts 4006 karma points
    Jan 14, 2010 @ 15:22
    Rich Green
    0

    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? 

  • Rich Green 2246 posts 4006 karma points
    Jan 14, 2010 @ 15:22
    Rich Green
    0

    Not an Umbraco project, just .NET but shouldn't be a problem.

  • Dan Evans 616 posts 988 karma points
    Jan 14, 2010 @ 15:41
    Dan Evans
    0

    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:

    http://www.fullcircleuk.com//scripts/fullcircleuk.com/gmap.js
  • Lee 1123 posts 3059 karma points
    Jan 14, 2010 @ 15:46
    Lee
    0

    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

     

    1. Making the DataType in the backend use the same 'hack' as the front end
    2. 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?

     

  • Lee 1123 posts 3059 karma points
    Jan 14, 2010 @ 15:48
    Lee
    0

    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?

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Jan 14, 2010 @ 15:59
    Tim Geyssens
    0

    @Lee the distance is calculated by some c#, so you'll need to mod the sourcecode or get/display the distance an other way.

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Jan 14, 2010 @ 16:05
    Tim Geyssens
    0

    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.

  • Lee 1123 posts 3059 karma points
    Jan 14, 2010 @ 16:18
    Lee
    0

    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 :(

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Jan 14, 2010 @ 16:29
    Tim Geyssens
    0

    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

  • Dan Evans 616 posts 988 karma points
    Jan 14, 2010 @ 16:43
    Dan Evans
    0

    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?

  • Lee 1123 posts 3059 karma points
    Jan 14, 2010 @ 18:25
    Lee
    0

    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
  • Rich Green 2246 posts 4006 karma points
    Jan 14, 2010 @ 18:30
    Rich Green
    0

    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

  • Rich Green 2246 posts 4006 karma points
    Jan 14, 2010 @ 19:03
    Rich Green
    0

    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

  • Rich Green 2246 posts 4006 karma points
    Jan 14, 2010 @ 19:06
    Rich Green
    0

    Where are you getting the lng and lat for your shops from? 

  • Dan Evans 616 posts 988 karma points
    Jan 14, 2010 @ 19:37
    Dan Evans
    0

    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.

  • Rich Green 2246 posts 4006 karma points
    Jan 14, 2010 @ 20:15
    Rich Green
    0

    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?

     

     

  • Lee 1123 posts 3059 karma points
    Jan 14, 2010 @ 21:27
    Lee
    0

    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

  • Lee 1123 posts 3059 karma points
    Jan 14, 2010 @ 22:58
    Lee
    0

    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

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Jan 14, 2010 @ 23:02
    Tim Geyssens
    0

    @Lee, awesome ! Would love to see the changes to I can get them added and update the package.

  • Lee 1123 posts 3059 karma points
    Jan 14, 2010 @ 23:05
    Lee
    0

    Do you want me to try and add them via codeplex Tim?

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Jan 14, 2010 @ 23:07
    Tim Geyssens
    0

    @Lee sure, what's your codeplex username ? I'll add you as a developer on the project then you can commit your changes.

  • Lee 1123 posts 3059 karma points
    Jan 14, 2010 @ 23:18
    Lee
    0

    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

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Jan 14, 2010 @ 23:21
    Tim Geyssens
    0

    Sure Lee that's perfect ! Got somewhere we can test the changes ?

    Cheers,
    Tim

  • Lee 1123 posts 3059 karma points
    Jan 14, 2010 @ 23:25
    Lee
    1

    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

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Jan 14, 2010 @ 23:29
    Tim Geyssens
    0

    sweet, you can send them to tg(at)umbraco(dot)dk

  • Lee 1123 posts 3059 karma points
    Jan 15, 2010 @ 11:52
    Lee
    0

    Just so you all know I have sent it over to Tim now to look over :)

  • DavidS 17 posts 38 karma points
    Apr 09, 2010 @ 23:48
    DavidS
    0

    Hey Tim,

    Is there any update on when the package might get updated with Lee's changes?

    TIA,

    David

  • 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.

Please Sign in or register to post replies