Hi everyone,
I have been trying very hard to do research and test things out.
Currently, I have a project that needs to do proximity searching in Drupal 6 and I spent too much time on searching and testing that my deadline is getting close. Yet, my project is not working yet. I really hope that someone can help me out.
Currently, I have CCK, GMap, Location, Location CCK, and Views modules install on my website. I put in the Google API key in the GMap setting and my content type uses Location CCK for the address. I followed several instructions which most of them are very similar and said it works:
http://groups.drupal.org/node/27752
http://drupal.org/node/359463
http://drupal.org/node/357295
After trying them, I still could not get it to work.
With http://groups.drupal.org/node/27752 , it did not show what the end result may be, so I assume there is no map for this one. After I followed it, I was only able to bring up the nodes if I do not enter any zip code and miles. Therefore, this doesn't work.
On http://drupal.org/node/359463 , I redid everything and followed step-by-step, the difference from the link above and this link was the setting in the View for Style. At the end of my testing, I got no map and no results no matter what I typed in the search.
When I looked up my database table, I saw the lat and lng columns show as "0".
I also tried to see if I can follow Google's Store Locator instruction http://code.google.com/intl/en-EN/apis/maps/articles/phpsqlsearch.html and got stuck with the SQL statement and XML output part because it didn't say what kind of user name and password I should enter.
My end goal is to build a feature that can enable users to enter City, State, Zipcode (or at least just the zipcode) to find a list of nodes that is within whatever mile radius the users put in.
I really appreciate your time.
Comments
On my site at
On my site at www.dance-ottawa.com, i use the core, not CCK, location for the user. For all other nodes of interest, I have the location in CCK location values.
I am not searching by zip, or anything quite that complex yet, but I do have proximity and maps working. Take a look at the 'Dance-Schools' page for example.
It uses as a base location the location of Ottawa, Canada, but users can log in and set their own personal location, then all measurements are from their location instead.
Is that of help?
Thank you dpatte
Thank you for the reply. The main feature of my project definitely needs the search function so users can search any areas in the US.
p.s. I really like your website though.
Sorry, you'll have to rebuild with Core CCK
I had built a site with Location CCK because everything I was reading indicated it was the future. I had to delete all the nodes using Location CCK and re-import them as Core Location. Everything is working great now as you can see here: http://2pedal.com
I had some big guns (krenyen and bdragon) look at it and they confirmed that it could not be done with Location CCK as it stands. And the work needed to get Location CCK to work was too much for anyone to take on at the time. I'm not sure what the current status of Location CCK is, but I don't think it's ready yet.
A little more info?
Hi 3goose,
Thank you for your reply also. I clicked around your website and did not find a proximity searching feature. But I saw that you used Location and View to list all the events and each has a map link in its node. That is nice.
Eventually, this website I work on will have a lot of content for the users search around and this feature should help them narrow down to what they are looking for.
I will continue to do my research and look forward to hear more ideas from you.
3goose : what modules did you use?
Hi 3goose, I like your site. I am trying to build similar but for martial arts schools worldwide. I particularly like your listings page http://2pedal.com/shops which shows the regions in which there are Bike Shops and the number of shops in brackets e.g. Pennslyvania (22).
Can you tell me the following?
1.) Is this number in brackets dynamically update e.g. if an authenticated user adds another bike shop to Pennsylvania will the number increment to 23 automatically?
2.) Is the inclusion of a Country or State on the page itself dynamic e.g. If I were to add a bike shop in Spain (which currently is not listed) would Spain(1) then appear on this page automatically or do you add it in manually?
Hopefully the answer to both of the above is YES, it's all automatic with views or something, reading from user inputted data. In which case my last question would be what is the list of modules you used to get this baby working??
Thanks for your contribution so far. Nice site!
Cientista
Yes, it's automatic, kind of...
Because I have a hierarchy that is controlled by the weight of information, every node has a hierarchical taxonomy location name in addition to a lat long position. Because of the amount of information I have, Canada and the US are on the same level as Europe, with the US states and Canadian provinces at the same level as other countries.
I'm a themer, not a developer, so this might not be the best way to do this, but it works for me. The information you are asking about is in a custom block placed on that page only. A region term doesn't show if the count is zero, and the count updates automatically. Here's the code:
<?php$country_array = array(44, 114, 113, 116);
?>
<?php$country_name_array = array('USA', 'Canada', 'Europe', 'Oceania');
?>
<?php foreach ($country_array as $id => $subcountry): ?><?php $taxarray = taxonomy_get_tree(5, $subcountry); ?>
<div class="country-term-list">
<h3 class="parent-region"><?php print $country_name_array[$id]; ?></h3>
<ul>
<?php foreach ($taxarray as $id => $subtax): ?>
<?php $shop_count = taxonomy_term_count_nodes($subtax->tid, $type = 'bike_shop'); ?>
<?php if ($shop_count > 0): ?>
<li class="child-region">
<?php print l($subtax->name,'taxonomy/term/'.$subtax->tid); ?> (<?php print $shop_count; ?> shop<?php if ($shop_count > 1) print 's'; ?>)
</li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
</div>
<?php endforeach; ?>
countries taxonomy
Hi 3goose, well I went in and added you a new bike shop and I saw that you have made a hierarchical taxonomy of countries with UK states and EU countries as their parent. The taxonomical approach is one I've been considering, I'm not sure if it is the one for me however as I will need to drill down to cities in two massive areas of node locations - Brazil and the US. If I could hijack the information my users entered in locaton and make that spit out a hierachical taxonomy that would be ideal.
My question is this - how did you get your hierarchical taxonomy in there? Was it hand crafted? WEhat would you do if someone wanted to enter a bikeshop in Lithuania (not in your taxonomy)?
I have seen other modules around such as 'addresses' and 'geolocation' which aim to get a list of coutnires in Drupal. It's all quite confusing really!
Cheers,
Andy
Have you tried this tutorial
Have you tried this tutorial http://svendecabooter.be/blog/implementing-location-proximity-search-for...?
If youre going to NOT use map modules you have to understand this tutorial http://code.google.com/intl/en-EN/apis/maps/articles/phpsqlsearch.html and username and password you have to get from your host. You can get a lot of help here http://groups.google.com/group/google-maps-api/topics
Tried svendecabooter...
Hi tinem,
Thank you for your response, too. I did try svendecabooter.be and it was very detailed instruction as well. But it did not work for me. I tried to contact the author and never heard back from him. I am not sure when was that posted. From what I've been researched, it seems GMap and Location CCK somehow worked at one point, then stopped working again. Some people tried to patch it and other issues came up or it just somehow stopped working, again...
I will keep everyone updated if I found something else.
I will try the Google Map tutorial again. Once I get it to work, I'll probably need your help on explaining how you connect it with the Drupal database.
Thanks!
Google Map + Drupal Database
Hi tinem,
I was successfully making the Google Map to work. Now I need to use it with the Drupal database. Since I've been trying different methods, I already have an U.S. zipcode database created from the Location module. The lat and lng columns of this Location module version are not reversed as other forums mentioned. With your experience, can you please guide me a little more? I know some modification will be needed because the Google Map tutorial's database is different than what we have:
Google Map - name, address, lat, lng --> search by address
Zipcode from Location Module - zip, city, state, lat, lng, time zone... --> my project needs it to be search by 3 text fields: city, state, zip. After that, how do the Drupal nodes connect as the results and display in View?
Do you know if there is a way to have multiple search features on one map? (Perhaps it'll show 2 color groups of markers.)
I really appreciate you and other group members' help.
@myst.riven said: my project
@myst.riven said: my project needs it to be search by 3 text fields: city, state, zip
But what should the site be about? I mean what should be found? On my site it's officials toilets.
http://www.tinemuller.dk/test_drupal/ - Dropdown Hovedstaden - Københavns kommune: from here you can see the address, zipcode and city for what's on the site until now. Now try searching for one of this from "Hele Danmark Radius" - Is it something like this you are going to make?
Let us see the map you have made from the tutorial, please? You have to make ALL this OUTSIDE Drupal first and THEN begin to think how you can use it in Drupal. But you can't expect to make this in a hurry. It took my years studying Google Maps API and when I couldn't find any module in Drupal I made it "my own way" without these modules. And it has also taken me a lot of time and struggling and I'm not a very practicing programmer but I'm very stubborn and creative and don't give up. So I have to say I'm VERY proud of what I have made here. :-)
Yes, I would like to have the same feature as your site
Hi tinem,
I had sent you an email with the map I created from the Google Store Locator tutorial. The map was not working earlier because I was trying to connect it to my Drupal database by changing the code, which I had no success. If you click on that link again right now, you'll see the map is exactly what the tutorial result would be - working fine (I had restored my tutorial files.)
Your website is exactly what I am looking for because it's the best I've seen so far. My project should be more complex, but it's nothing if it doesn't work. My project will have 2 different roles of users: one will create new content by entering a street address in, the other role will be searching for all nodes within a radius after entering any address in.
These few days, I've been trying and still have no luck. Perhaps I am modifying my code wrong? Within the next hour, I'll post my modified code from phpsqlsearch_genxml.php because I want to keep trying as well. Please let me know if you see any errors after I post it and I really appreciate your time and help.
Thank you!
Myst.
After I keep trying...
Hi tinem,
I am going to include my code here because I tried again and it's not working. I will also explain what is in my database so you can have more information and let me know where I've done wrong.
(I am going to keep comparing with Google tutorial's markers table since that one works.)
As I described before that I am using Location and Location CCK modules. I found a table in my Drupal database called "drup_location". In that table, there are these columns: lid, name, street, additional, city, province, postal_code, country, latitude, longitude, source, is_primary
I have values in all columns except the "additional" column because I did not enter anything in that text field when I created my nodes. (That shouldn't affect anything.)
I then go to my phpsqlsearch_genxml2.php file (I renamed it with a 2 so I can still refer back to the original "phpsqlsearch_genxml.php" file) and I modified "lat" to "latitude", "lng" to "longitude", "address" to "street".
There is a comment in the file says "Search the rows in the markers table", I assume the file looks for the name of the table here... (?)
So I changed
AS distance FROM markers HAVING distance < '%s' ORDER BY distance LIMIT 0 , 20",to
AS distance FROM drup_location HAVING distance < '%s' ORDER BY distance LIMIT 0 , 20",There are 2 more places in the code showing "markers", but I assume those were just to set the functions. I did try to change them and it's not working, so I changed them back. Here's my php code:
<?php
require("phpsqlsearch_dbinfo.php");
// Get parameters from URL
$center_latitude = $_GET["latitude"];
$center_longitude = $_GET["longitude"];
$radius = $_GET["radius"];
// Start XML file, create parent node
$dom = new DOMDocument("1.0");
$node = $dom->createElement("markers");
$parnode = $dom->appendChild($node);
// Opens a connection to a mySQL server
$connection=mysql_connect (localhost, $username, $password);
if (!$connection) {
die("Not connected : " . mysql_error());
}
// Set the active mySQL database
$db_selected = mysql_select_db($database, $connection);
if (!$db_selected) {
die ("Can\'t use db : " . mysql_error());
}
// Search the rows in the markers table
$query = sprintf("SELECT street, name, latitude, longitude, ( 3959 * acos( cos( radians('%s') ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians('%s') ) + sin( radians('%s') ) * sin( radians( latitude ) ) ) ) AS distance FROM drup_location HAVING distance < '%s' ORDER BY distance LIMIT 0 , 20",
mysql_real_escape_string($center_latitude),
mysql_real_escape_string($center_longitude),
mysql_real_escape_string($center_latitude),
mysql_real_escape_string($radius));
$result = mysql_query($query);
if (!$result) {
die("Invalid query: " . mysql_error());
}
header("Content-type: text/xml");
// Iterate through the rows, adding XML nodes for each
while ($row = @mysql_fetch_assoc($result)){
$node = $dom->createElement("marker");
$newnode = $parnode->appendChild($node);
$newnode->setAttribute("name", $row['name']);
$newnode->setAttribute("street", $row['street']);
$newnode->setAttribute("latitude", $row['latitude']);
$newnode->setAttribute("longitude", $row['longitude']);
$newnode->setAttribute("distance", $row['distance']);
}
echo $dom->saveXML();
?>
Do I need to set more Attribute near the end of that file because I have more columns? If I do, how would it work if that's the only place I set it up and not use it?
The link of the map I am trying to modify is named map2.html instead of map.html, so I can still compare the two.
I would really appreciate it if you can check it for me. Thank you very much!
(For other group members that would like to see my test site, please contact me through my profile and I will send you the url. I apologize that I cannot show it in public. Thank you.)
All this questions is about
All this questions is about Google Maps API and you will get much more feedback if you ask in the forum http://groups.google.com/group/google-maps-api/topics or search for "storelocator" and you will see a lot of other people ask'ed for help including myself. Or search for "storelocator" in this group too. Also a discussion here http://groups.drupal.org/node/30074#comment-154098 where I explain how I did it the first time. I can't garantie this is how I do it now but maybe you can learn something from this and get some ideas or maybe contact the guy who made a Module of this.
I will keep you all updated on how I do.
During my research, including reading a lot other posts by tinem, I know that many people want to know how this works. I will keep everyone posted on how I do. Unfortunately, my project time is running out soon since I already spent a lot of time on researching, testing, and troubleshooting different things. I will continue to try the directions tinem points me to (and whatever other ways I can think of). Hopefully I'll succeed soon and show all details on what I've done. Wish me luck and I'll be back here soon when I have more questions.
Thank you.
Still no luck...
Hi,
Another day has passed by and I still cannot get things to work. I got some help from the author of http://groups.drupal.org/node/27752 and they recommended me to check the versions of modules and core. I did use the most recent version of Drupal. Just being desperate to see something working, I installed a brand new Drupal website with all the older versions matching this tutorial and no other modules there to confuse me. At the end, I did not have any good news.
I also contacted Google Map API forum and did not get any help after the entire day. I really hope someone can help me.
Tinem, I looked up all your posts from Google Group and you mentioned about many people have succeed in making this. I found them in different discussions but no one had ever replied to me when I contacted them. Can you please help me?
http://groups.google.com/group/google-maps-api/browse_thread/thread/cd2b...
I have 80+ tables created from Drupal. My question is, how does "phpsqlsearch_genxml.php" know which table to select?
Can someone please help me?
Thanks.
I've got it!
First, I want to thank all of you (including Terry with the custom module who didn't post here) for all the help you provided. Special thanks to TineM. My skill level is still far from yours, but I re-read your other posts many times and I picked up little things each time. You have amazing code on your website, too!
I was able to get help from Google Map API group and learned some tricks on how to troubleshoot instead of seeing a page not working.
I am not sure if I can post my code here for others since this is for Drupal and not Google Map, but feel free to contact me if you want to know what I did. I am willing to share my code and explain in details. I believe in helping each other. Now it's my turn to reach my hand out.
Love to learn what you have achieved
I would really appreciate seeing what you have achieved so far. Can you provide a link to any code or narrative?
I will post my code and link here soon
Thank you for your interest. I have also receive a lot of requests in email regarding my test site. The website I am currently working on has confidential information. I am building a new test site with random addresses so I can post and share with the Drupal community. I will be posting here again within a day or two and share more information with everyone.
Thank you for your patience.
Code right here
Hi everyone, sorry that I've been so busy that I am not done with my test site. But I am going to explain what I did on my site right here. I hope that will help, then having the test site soon will provide the link for you to see what I did exactly.
One thing I have to clarify is, my skills are limited that my way of doing things is not the best. Currently, my map is working on my Drupal site and it's pulling all the nodes I wanted, but I have unsolved problem: how do I have these map results link to my node? (I am still trying to figure out from Tinem's code. Hers is very custom and works perfectly.)
So, here's what I have so far... (with so many testings I've done, I may or may not have some extra steps here that are not needed.)
I installed Location CCK, Location, Views, CCK, GMap modules on my site. Inside the Location module folder, there is one called database folder. I imported the US zipcode into my drupal's zipcode table. I made a custom content type and created a Location CCK field under "manage fields" of that content type. I then created several new content that belong to this content type for testing purpose. I went to my database to make sure there is a table called "drp_location" (or at least a similar name because I don't know how everyone's system is like). *You have to make sure the latitude and longitude values of these content are showing real numbers, not 0.000000
Once the table and everything is set up and make sure you have your own Google map api key, (I would still recommend to do the Google map store locator tutorial so you can understand the whole idea better, there are more need to set up then just the 2 main files I am showing here,) here are my code:
This is my phpsqlsearch_genxml.php that generates the xml file for your map to recognize:
<?php
require("phpsqlsearch_dbinfo.php");
// Get parameters from URL
$center_latitude = $_GET["latitude"];
$center_longitude = $_GET["longitude"];
$radius = $_GET["radius"];
// Start XML file, create parent node
$dom = new DOMDocument("1.0");
$node = $dom->createElement("markers");
$parnode = $dom->appendChild($node);
// Opens a connection to a mySQL server
$connection=mysql_connect (localhost, $username, $password);
if (!$connection) {
die("Not connected : " . mysql_error());
}
// Set the active mySQL database
$db_selected = mysql_select_db($database, $connection);
if (!$db_selected) {
die ("Can\'t use db : " . mysql_error());
}
// Search the rows in the location table
$query = sprintf("SELECT street, name, city, province, postal_code, latitude, longitude, ( 3959 * acos( cos( radians('%s') ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians('%s') ) + sin( radians('%s') ) * sin( radians( latitude ) ) ) ) AS distance FROM drp_location HAVING distance < '%s' ORDER BY distance LIMIT 0 , 20",
mysql_real_escape_string($center_latitude),
mysql_real_escape_string($center_longitude),
mysql_real_escape_string($center_latitude),
mysql_real_escape_string($radius));
$result = mysql_query($query);
if (!$result) {
die("Invalid query: " . mysql_error());
}
header("Content-type: text/xml");
// Iterate through the rows, adding XML nodes for each
// This is where you add the rows from your database table. "name" is what you want to name it in the XML file, $row['name'] is the name from the table.
while ($row = @mysql_fetch_assoc($result)){
$node = $dom->createElement("marker");
$newnode = $parnode->appendChild($node);
$newnode->setAttribute("name", $row['name']);
$newnode->setAttribute("street", $row['street']);
$newnode->setAttribute("city", $row['city']);
$newnode->setAttribute("province", $row['province']);
$newnode->setAttribute("postal_code", $row['postal_code']);
$newnode->setAttribute("lat", $row['latitude']);
$newnode->setAttribute("lng", $row['longitude']);
$newnode->setAttribute("distance", $row['distance']);
}
echo $dom->saveXML();
?>
* It is very important that your php file is generating values. You can use Firefox or IE to test it by entering this as your url (please enter in your own domain):
http://www.yourdomain.com/phpsqlsearch_genxml.php?lat=41.850033&lng=-87....
(This would show the values if you entered Chicago as the searching location.)
In my map.html file, I have my somewhat custom code:
<script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAA6Y9jprQQ7_CCjKY-dH4KChTRERdeAiwZ9EeJWta3L_JZVS0bOBRyvsoibgk-j-W7WE9RxsVi7_GGqg" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
var map;
var geocoder;
function load() {
if (GBrowserIsCompatible()) {
geocoder = new GClientGeocoder();
map = new GMap2(document.getElementById('map'));
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng(40, -100), 4);
}
}
function searchLocations() {
var street = document.getElementById('addressInput').value;
geocoder.getLatLng(street, function(latlng) {
if (!latlng) {
alert(street + ' not found');
} else {
searchLocationsNear(latlng);
}
});
}
function searchLocationsNear(center) {
var radius = document.getElementById('radiusSelect').value;
var searchUrl = 'phpsqlsearch_genxml?latitude=' + center.lat() + '&longitude=' + center.lng() + '&radius=' + radius;
GDownloadUrl(searchUrl, function(data) {
var xml = GXml.parse(data);
var markers = xml.documentElement.getElementsByTagName('marker');
map.clearOverlays();
var sidebar = document.getElementById('sidebar');
sidebar.innerHTML = '';
if (markers.length == 0) {
sidebar.innerHTML = 'No results found.';
map.setCenter(new GLatLng(40, -100), 4);
return;
}
// This is where you set the name to connect from the XML file and bring the values into the marker.
var bounds = new GLatLngBounds();
for (var i = 0; i < markers.length; i++) {
var name = markers[i].getAttribute('name');
var street = markers[i].getAttribute('street');
var city = markers[i].getAttribute('city');
var province = markers[i].getAttribute('province');
var postal_code = markers[i].getAttribute('postal_code');
var distance = parseFloat(markers[i].getAttribute('distance'));
var point = new GLatLng(parseFloat(markers[i].getAttribute('lat')),
parseFloat(markers[i].getAttribute('lng')));
var marker = createMarker(point, name, street, city, province, postal_code);
map.addOverlay(marker);
var sidebarEntry = createSidebarEntry(marker, name, street, city, province, postal_code, distance);
sidebar.appendChild(sidebarEntry);
bounds.extend(point);
}
map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds));
});
}
// set up what you want to appear in the marker bubble
function createMarker(point, name, street, city, province, postal_code) {
var marker = new GMarker(point);
var html = '<b>' + name + '</b> <br/>' + street + '<br />' + city + ', ' + province + ' ' + postal_code;
GEvent.addListener(marker, 'click', function() {
marker.openInfoWindowHtml(html);
});
return marker;
}
// set up what you want to appear in the side bar ara
function createSidebarEntry(marker, name, street, city, province, postal_code, distance) {
var div = document.createElement('div');
var html = '<b>' + name + '</b> (' + distance.toFixed(1) + ')<br/>' + street + '<br />' + city + ', ' + province + ' ' + postal_code;
div.innerHTML = html;
div.style.cursor = 'pointer';
div.style.marginBottom = '5px';
GEvent.addDomListener(div, 'click', function() {
GEvent.trigger(marker, 'click');
});
GEvent.addDomListener(div, 'mouseover', function() {
div.style.backgroundColor = '#eee';
});
GEvent.addDomListener(div, 'mouseout', function() {
div.style.backgroundColor = '#fff';
});
return div;
}
//]]>
</script>
</head>
<body onload="load()" onunload="GUnload()">
Address: <input value="" type="text" id="addressInput"/>
Radius: <select id="radiusSelect">
<option value="25000" selected>25000</option>
<option value="25">25</option>
<option value="100">100</option>
<option value="200">200</option>
</select>
<input type="button" onclick="searchLocations()" value="Search Locations"/>
<br/>
<br/>
<div style="width:600px; font-family:Arial,
sans-serif; font-size:11px; border:1px solid black">
<table>
<tbody>
<tr>
<td width="200" valign="top"> <div id="sidebar" style="overflow: auto; height: 400px; font-size: 11px; color: #000"></div>
</td>
<td> <div id="map" style="overflow: hidden; width:400px; height:400px"></div> </td>
</tr>
</tbody>
</table>
</div>
So I highly recommend my code as a reference since I am still in the process of working on this.
Thanks.
Thanks for sharing this. It
Thanks for sharing this.
It is not quite what I was hoping for. I am building a custom module to do this.
First off, I was using an external database to Drupal. So under sites/default/settings.php, I set up $db_url to be an array:
$db_url['default'] = 'mysqli://username:password@localhost/databasename';$db_url['store_locator'] = 'mysqli://username:password@localhost/databasename';
This is my genxml.php. I have tried it both ways as a stand alone php file and as a hook_menu callback.
<?php
// Get parameters from URL
$lat = $_POST["lat"];
$lng = $_POST["lng"];
$radius = $_POST["radius"];
dsm($lat);
db_set_active('store_locator');
// Search the rows in the markers table
$result_calc = db_query("SELECT address, name, lat, lng,
( 3959 * acos( cos( radians('%f') ) * cos( radians( lat ) )
* cos( radians( lng ) - radians(%f) ) + sin( radians('%f') )
* sin( radians( lat ) ) ) )
AS distance FROM {finder_markers} HAVING distance < '%d'
ORDER BY distance LIMIT 0 , 20", $lat, $lng, $lat, $radius);
$result = db_result($result_calc);
// Start XML file, create parent node
header("Content-Type: text/xml; charset=utf-8");
$dom = new DOMDocument("1.0");
$node = $dom->createElement("markers");
$parnode = $dom->appendChild($node);
// Iterate through the rows, adding XML nodes for each
while ($row = db_fetch_array($result)){
$node = $dom->createElement("marker");
$newnode = $parnode->appendChild($node);
$newnode->setAttribute("name", $row['name']);
$newnode->setAttribute("address", $row['address']);
$newnode->setAttribute("lat", $row['lat']);
$newnode->setAttribute("lng", $row['lng']);
$newnode->setAttribute("distance", $row['distance']);
}
echo $dom->saveXML();
db_set_active('default');
Right now I am stuck on several issues:
Drupal strips my parameters from the URL when I pass them to the genxml function. I have tried various custom wildcard solutions to no love. (path/%) or path/%lat/%lng/%radius/
Drupal throws an XML parsing error (Junk document definition), in the body of the html output, markers becomes a wrapper around the body tag.
When I hardcode the values into the MySQL query, it throws mysqli string warnings.
I am doing this variation independent of gmap and location modules. I have tried a solution with both of those modules. The showstopper there for me is the default country limitation. I need to have multiple countries available as if all the countries were default.
I hope this helps someone. If there is an obvious thing that needs correcting, please show me, I am all ears.
~kyle
PS I have tried $_REQUEST, $_POST and $_GET for the variables.
Kyle Schweighauser, Director of Information Technology
Extanto,LLC. | 349 North Polk Street | Eugene , OR 97402
Office 541.515.6232
http://www.extanto.com/
ANOTHER SOLUTION! - Proximity Search but no map
Hi everyone,
If you are looking for a Drupal solution for Proximity Search in D6 and no map, I found a solution for you!
If you are doing a lot of research, you've probably read the discussions/issues where many people are having problems setting this up because it does not return any results after you build it in Views. Thank to my good friend, mine is working perfectly! You just need to download the DEVELOPMENT version of Location module. DO NOT use Location CCK. After that, go edit your content type (not Manage Fields) and there should be a "Locative Information" and click on "Collection Settings" to set up what you want. When you Manage Fields, you'll see "Location" showing up and you can put it in whatever order you want among the fields. Other than that, you pretty much just follow all the Drupal Proximity Search by Zip Code tutorials out there and it will work at the end.
Sorry I cannot type everything in details here right now. But I just want to let some people know that this does work! I have a crazy week, but I will try my best to type more details in as soon as I can.
Myst
Use Development version of Gmap module too
I have had best success with this module using the Gmap module.
You may have issues with Views (eg: field not displaying in gmap popups) and wind up searching location module discussions for fixes. It is in fact an issue with Gmap and views.
Bets of luck. I only started Drupal development last year and managed to get Proximity Search working.
PS: Don't forget to load a postcodes database (non-drual sql import) to search against.
Drupal Location module: Zip Code Proximity Search
This is NOT how I do it but maybe this tutorial http://oshyn.com/_blog/Web_Content_Management/post/Drupal_Location_Modul... can help some of you.
Compare 2 proximity searches?
How would you go about finding a location that is between 2 other locations? As in:
Locations A, B & C all exist in the database.
In real life, if you were to travel from A to C, you'd pass B.
I need to build a view that let's you know that B is on the way if we already know about A & C.
I guess if I did a proximity search on A and C (using a proximity range equal to the distance between A & C) and then filter a view to only show results that appear in both proximity searches, that would kind of work. Can anybody suggest a better way?
spatial queries instead
I believe you can use direct spatial queries (assuming your db supports them) to figure this out.
This is probably slow and doesn't take into account that driving is not a straight line affair. However, you could calculate it periodically and cache results and over a sufficiently long distance a straight line comparison is close enough to reality to make it worth it, I think.
knaddison blog | Morris Animal Foundation
Independently of Drupal?
Are you saying that this would need to be done independently of Drupal? I.e. not via Views or some helper module?
Thanks for the input.
in Drupal, but custom code
I'm suggesting it would be in Drupal, but completely custom code.
knaddison blog | Morris Animal Foundation
Is it possible by now to
Is it possible by now to achieve proximity search using Location CCK?