Hello all,
Im trying to make a drupalsite with a storelocator in it. With that i mean a googlemap with the store locations in it. Above that map there should be a filter where you can fill in your postcode so it give you the closest store back.
I found some diffirent tutorials on the net that discribe how this is done, like:
http://svendecabooter.be/blog/implementing-location-proximity-search-for...
http://drupal.org/node/359463
But when trying those i found out that i needed a postcode database. For that i went to:
http://kvdb.net/projects/6pp/downloads
and downloaded the 6pp database (format: 1234 AB). I made a python program to make an output for the drupal db. I might be handy for other users so here it is. use it like this:
./dbconverter.py >> zipcodes.nl.mysql
When your database is done, i imported it this way:
db # mysql -u root -p drupal < zipcodes.nl.mysql
Enter password:
db #
!/usr/bin/python#import sys
from os.path import exists
Q = list()##def addInsert(line):
x = line.split(',')
Q.append("INSERT INTO zipcodes VALUES('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}');".format(x[1],x[0],'ZHO',x[6],x[7],1,1,'nl'))
csvfile = "/var/www/localhost/htdocs/ecolamp/db/6pp_zh.csv"
if not exists(csvfile):
print "path doesnt exists noob"
exit(-1)
try:
f = open(csvfile,'r')#except Exception,e:
print "Cant open {0}: {1}".format(file,e)
l = 1
for line in f:
if l != 1:
addInsert(line.rstrip('\r\n'))
l += 1
for x in Q:
print x
This is a short example how it came out:
INSERT INTO zipcodes VALUES('7705 PA','Drogteropslagen','DRE','52.61666700','6.50000000','1','1','nl');
INSERT INTO zipcodes VALUES('7705 PB','Drogteropslagen','DRE','52.61666700','6.50000000','1','1','nl');
INSERT INTO zipcodes VALUES('7705 PC','Drogteropslagen','DRE','52.61666700','6.50000000','1','1','nl');
INSERT INTO zipcodes VALUES('7705 PD','Drogteropslagen','DRE','52.61666700','6.50000000','1','1','nl');
INSERT INTO zipcodes VALUES('7705 PE','Drogteropslagen','DRE','52.61666700','6.50000000','1','1','nl');
INSERT INTO zipcodes VALUES('7705 PG','Drogteropslagen','DRE','52.61666700','6.50000000','1','1','nl');
INSERT INTO zipcodes VALUES('7705 PH','Drogteropslagen','DRE','52.61666700','6.50000000','1','1','nl');
INSERT INTO zipcodes VALUES('7705 PJ','Drogteropslagen','DRE','52.61666700','6.50000000','1','1','nl');
INSERT INTO zipcodes VALUES('7705 PL','Drogteropslagen','DRE','52.61666700','6.50000000','1','1','nl');
INSERT INTO zipcodes VALUES('7705 PM','Drogteropslagen','DRE','52.61666700','6.50000000','1','1','nl');
INSERT INTO zipcodes VALUES('7740 AA','Coevorden','DRE','52.66666700','6.75000000','1','1','nl');
INSERT INTO zipcodes VALUES('7740 AD','Coevorden','DRE','52.66666700','6.75000000','1','1','nl');
INSERT INTO zipcodes VALUES('7740 AE','Coevorden','DRE','52.66666700','6.75000000','1','1','nl');
INSERT INTO zipcodes VALUES('7741 AB','Coevorden','DRE','52.66666700','6.75000000','1','1','nl');
INSERT INTO zipcodes VALUES('7741 AC','Coevorden','DRE','52.66666700','6.75000000','1','1','nl');
INSERT INTO zipcodes VALUES('7741 AD','Coevorden','DRE','52.66666700','6.75000000','1','1','nl');
INSERT INTO zipcodes VALUES('7741 AE','Coevorden','DRE','52.66666700','6.75000000','1','1','nl');
INSERT INTO zipcodes VALUES('7741 AG','Coevorden','DRE','52.66666700','6.75000000','1','1','nl');
I'm using:
Location: 6.x-3.1-rc1
GMap: 6.x-1.x-dev
Views: 6.x-2.7
Okay, so far so good.
Next i made a new view with these settings:
http://img8.imageshack.us/img8/3980/locator1.jpg
That gave me this output in previewmode:
http://img195.imageshack.us/img195/9749/locator2.jpg
SELECT node.nid AS nid,
'Unknown' AS location_distance_0,
location.latitude AS location_latitude,
location.longitude AS location_longitude,
node.title AS node_title
FROM node node
LEFT JOIN location_instance location_instance ON node.vid = location_instance.vid
LEFT JOIN location location ON location_instance.lid = location.lid
WHERE (node.type in ('shop')) AND (node.status <> 0) AND (0)
Im wondering about the:
'Unknown' AS location_distance_0,
Is that correct?
Anywayz, my aim is to get this output:
http://svendecabooter.be/sites/svendecabooter.be/files/upload/proximity_...
but im getting this:
http://img195.imageshack.us/img195/8990/locator3.jpg
This thing is driving me crazy sinds i tried it over and over again. I don;t got a clue anymore where to look for :P The map nor the filters are working.
So, is there anyone that can help me get a working storelocator?
Thanks in advance :)
Grtz Remco
Comments
Maybe our discussion here
Maybe our discussion here http://groups.drupal.org/node/30074 can help you getting further. Welcome in the club to get this functioning in Drupal and hopefully the Drupal way in the end. :-)
Hey tinem :) Thanks for your
Hey tinem :)
Thanks for your reply. I just red true your discussion which seems very interesting. Tough im not sure how i can use it to accomplish form i'd like to have on my site.
Guess i stick to the old plan sinds i know it should be possible. I've seen some storelocators made with drupal in other country's aswell same way as i discribed above. I just need to know where i go wrong.. but cannot seem to find out where that is..... yet :P
Anywayz.. thanks for the info :)
grtz Remco
It could have something to do
It could have something to do with the latest update of views 7 as we also discuss here http://groups.drupal.org/node/34812 - let us hear if it help you installing an earliger views?
Ola :) Well.. i just
Ola :)
Well.. i just installed views 6.x-2.6 but still the same problems.. :/ So no luck so far..
//edit even tried views-6.x-2.5 now.. still nothing...
I did some research about this msg:
And i found out it was created by this piece of code:
But im not pretty sure what i means sinds im not mutch of a php coder. I'm wondering if it might have something to do with it...
Thanks in advance..
Grtz Remco :)
Initial Observations
Having just implemented something similar at www.sportrelief.com/the-mile/find-a-mile, one thing I did notice is that the map doesn't display if there are no markers to display. So, that probably accounts for your empty initial page.
Surely, you have to enter a postcode for this to work? Otherwise, there is no location from which to calculate distances. Your screenshot does not show anything entered in to the postcode field.
What values are you passing to the function location_distance_between?
HTH
Terry
Recent Drupal sites:-
www.allegiantair.com www.defaqto.com www.quarkexpeditions.com www.sportrelief.com www.chevronhackles.com
www.philipturnercrafts.co.uk www.intelflexplus.com www.aprilroseturner.com www.businessclubagent.ihg.com www.businessclub.ihg
As you can see here i added a
As you can see here i added a node location: https://www.ezme.nl/ecolamp/node/50
Then again, when you goto the storelocator here: https://www.ezme.nl/ecolamp/storelocator and fill in a postcode that is less then 100km from that place like "5864 AS", it gives you nothing back :( Also tried "5864" and "5864AS"
little sidenote:
Im using the 4pp database now as discribed here: http://drupal.org/node/73714#comment-2103112
with the patch that is uploaded there too
What values are you passing
What values are you passing to the function location_distance_between?
Are you sure that the post code you entered and the post code of the store are in the database?
Terry
Recent Drupal sites:-
www.allegiantair.com www.defaqto.com www.quarkexpeditions.com www.sportrelief.com www.chevronhackles.com
www.philipturnercrafts.co.uk www.intelflexplus.com www.aprilroseturner.com www.businessclubagent.ihg.com www.businessclub.ihg
I'm not sure how I can adjust
I'm not sure how I can adjust that location_distance_between value. I tought the module calculated that.
Anwayz.. just checked phpmyadmin and both postcodes are in the database
need more info
Please can you output the actual values that are being passed in to the location_distance_between function.
i.e. what numeric values are contained in $latlon_a, $latlon_b and $distance_unit?
This will help identify whether the problem is within location_distance_between or somewhere else.
Terry
Recent Drupal sites:-
www.allegiantair.com www.defaqto.com www.quarkexpeditions.com www.sportrelief.com www.chevronhackles.com
www.philipturnercrafts.co.uk www.intelflexplus.com www.aprilroseturner.com www.businessclubagent.ihg.com www.businessclub.ihg
Im not sure what you mean by
Sorry, but Im not sure what you mean by that? Is that the value that i give as input? Cause that is 5864. Else can you tell me where i can find those values?
I appriciate your help! Thanks in advance.
Grtz Remco
5864 is the value you enter
5864 is the value you enter in to the form. I am trying to ascertain what values are passed in to the function which does the distance calculation.
This is going to require modifying that function to output those values that I asked for.
The simplest way will be to insert the following code immediately after
function location_distance_between($latlon_a = array(), $latlon_b = array(), $distance_unit = 'km') {
This will output the values to the screen and stop the process.
Post the output back here and then remove that code. At least then, there will be somne idea of where the process is going awry.
Terry
Recent Drupal sites:-
www.allegiantair.com www.defaqto.com www.quarkexpeditions.com www.sportrelief.com www.chevronhackles.com
www.philipturnercrafts.co.uk www.intelflexplus.com www.aprilroseturner.com www.businessclubagent.ihg.com www.businessclub.ihg
ok this is what i did: i went
ok this is what i did:
i went to /modules/location/location.inc and changed the code like this:
Then went to https://www.ezme.nl/ecolamp/storelocator and gave in the 5864 postalcode. Nothing got returned :/
next it tried the same but by editing /modules/location/location.inc this way:
still no output on www.ezme.nl/ecolamp/storelocator
Also:
Gave nothing back
I guess that is what you ment right..?
Last thing i tried was adding: echo "testing"; and repeated the steps as discribed above
Even that didn't display any output. It seems the page doesn't call the function?
It certainly looks that way.
Looks like you will have to go back to the drawing board identifying where the problem really lies.
What led you to believe that the problem lay within that function in the first place?
Terry
Recent Drupal sites:-
www.allegiantair.com www.defaqto.com www.quarkexpeditions.com www.sportrelief.com www.chevronhackles.com
www.philipturnercrafts.co.uk www.intelflexplus.com www.aprilroseturner.com www.businessclubagent.ihg.com www.businessclub.ihg
Hahaha donno, i guess you
Hahaha donno, i guess you started to ask about it here: http://drupal.org/node/628558#comment-2256810 :D
Only in response to your previous comment which said ....
I did some research about this msg:
'Unknown' AS location_distance_0,
And i found out it was created by this piece of code: ....
Recent Drupal sites:-
www.allegiantair.com www.defaqto.com www.quarkexpeditions.com www.sportrelief.com www.chevronhackles.com
www.philipturnercrafts.co.uk www.intelflexplus.com www.aprilroseturner.com www.businessclubagent.ihg.com www.businessclub.ihg
Ah oki.. i see :) Like i said
Ah oki.. i see :) Like i said before, i appriciate it very mutch that your trying to think with me here. Thanks again :)
Some additional information,
Some additional information, you told me that when there was no information in the database, the map wont be displayed.
So i checked the other tables aswell and noticed some things. Check the screenshots:
location db:
http://img17.imageshack.us/img17/2438/db1s.jpg
Some lat/lon are not correct in the db
nodemap db:
http://img17.imageshack.us/img17/5792/db2c.jpg
Donno if this is how it should be.
Anwayz... Two nodes are displayed in the "Node locations" map: https://www.ezme.nl/ecolamp/map/node (something else then the storelocator view i made)
Okay, i got it working. Last
Okay, i got it working.
Last things i tried was moving around with the "Location map" block and applaying this patch here: http://drupal.org/files/issues/location-proximity-nl.patch
Thanks for all your help :)