PDA

View Full Version : Maps for Spanish Properties



hsad10
07-21-2004, 10:11 AM
Hi all,
Well... finally I got it working OK.
I have adapted some code to get a very accurate map in multimap.

I inseted this code in style.php (you can delete the old makeyahoomap function)


function makeMapQuestMap($listingID, $address_field, $city_field, $state_field, $zip_field)
{
// renders a link to yahoo maps on the page

global $conn, $config;
$sql_listingID = make_db_extra_safe($listingID);
$sql_address_field = make_db_safe($address_field);
$sql_city_field = make_db_safe($city_field);
$sql_state_field = make_db_safe($state_field);
$sql_zip_field = make_db_safe($zip_field);
// get address
$sql = "SELECT " . $config[table_prefix] . "listingsDBElements.field_value, " . $config[table_prefix] . "listingsFormElements.field_type, " . $config[table_prefix] . "listingsFormElements.field_caption FROM " . $config[table_prefix] . "listingsDBElements, " . $config[table_prefix] . "listingsFormElements WHERE ((" . $config[table_prefix] . "listingsDBElements.listing_id = $sql_listingID) AND (" . $config[table_prefix] . "listingsFormElements.field_name = " . $config[table_prefix] . "listingsDBElements.field_name) AND (" . $config[table_prefix] . "listingsDBElements.field_name = $sql_address_field))";
$recordSet = $conn->Execute($sql);
if ($recordSet === false)
{
log_error($sql);
}
while (!$recordSet->EOF)
{
$mapquest_address = make_db_unsafe ($recordSet->fields[field_value]);
$recordSet->MoveNext();
} // end while
// get city
$sql = "SELECT " . $config[table_prefix] . "listingsDBElements.field_value, " . $config[table_prefix] . "listingsFormElements.field_type, " . $config[table_prefix] . "listingsFormElements.field_caption FROM " . $config[table_prefix] . "listingsDBElements, " . $config[table_prefix] . "listingsFormElements WHERE ((" . $config[table_prefix] . "listingsDBElements.listing_id = $sql_listingID) AND (" . $config[table_prefix] . "listingsFormElements.field_name = " . $config[table_prefix] . "listingsDBElements.field_name) AND (" . $config[table_prefix] . "listingsDBElements.field_name = $sql_city_field))";
$recordSet = $conn->Execute($sql);
if ($recordSet === false)
{
log_error($sql);
}
while (!$recordSet->EOF)
{
$mapquest_city = make_db_unsafe ($recordSet->fields[field_value]);
$recordSet->MoveNext();
} // end while
// get state
$sql = "SELECT " . $config[table_prefix] . "listingsDBElements.field_value, " . $config[table_prefix] . "listingsFormElements.field_type, " . $config[table_prefix] . "listingsFormElements.field_caption FROM " . $config[table_prefix] . "listingsDBElements, " . $config[table_prefix] . "listingsFormElements WHERE ((" . $config[table_prefix] . "listingsDBElements.listing_id = $sql_listingID) AND (" . $config[table_prefix] . "listingsFormElements.field_name = " . $config[table_prefix] . "listingsDBElements.field_name) AND (" . $config[table_prefix] . "listingsDBElements.field_name = $sql_state_field))";
$recordSet = $conn->Execute($sql);
if ($recordSet === false)
{
log_error($sql);
}
while (!$recordSet->EOF)
{
$mapquest_state = make_db_unsafe ($recordSet->fields[field_value]);
$recordSet->MoveNext();
} // end while
// get zip
$sql = "SELECT " . $config[table_prefix] . "listingsDBElements.field_value, " . $config[table_prefix] . "listingsFormElements.field_type, " . $config[table_prefix] . "listingsFormElements.field_caption FROM " . $config[table_prefix] . "listingsDBElements, " . $config[table_prefix] . "listingsFormElements WHERE ((" . $config[table_prefix] . "listingsDBElements.listing_id = $sql_listingID) AND (" . $config[table_prefix] . "listingsFormElements.field_name = " . $config[table_prefix] . "listingsDBElements.field_name) AND (" . $config[table_prefix] . "listingsDBElements.field_name = $sql_zip_field))";
$recordSet = $conn->Execute($sql);
if ($recordSet === false)
{
log_error($sql);
}
while (!$recordSet->EOF)
{
$mapquest_zip = make_db_unsafe ($recordSet->fields[field_value]);
$recordSet->MoveNext();
} // end while
$mapquest_string = "client=public&lang=&advanced=&db=ES&cname=Great+Britain&overviewmap=&addr2=$mapquest_address&addr3=$mapquest_city&pc=$mapquest_zip";
//$yahoo_string = "Pyt=Tmap&addr=$yahoo_address&csz=$yahoo_ci ty,$yahoo_state&Get+Map=Get+Map";
echo "<a href=\"http://www.multimap.com/map/places.cgi?$mapquest_string\" target=\"_map\"><b>Ver Mapa del Area</b></a>";
} // end makeMapQuestMap

And replaced the link line in listingview.php

<br><?php makeMapQuestMap($listingID, "address", "city", "state", "postcode") ?>

And it works fine. It will open a new window showing the map.
NOTE: THIS PAGE IS IN ENGLISH

Enjoy!

Hugo

asitudela
07-21-2004, 11:42 AM
It Works good althought just in English.

Ahh, in listingview you have to put:

<?php makeMapQuestMap($listingID, "address", "city", "state", "zip") ?>


Bye

hsad10
07-21-2004, 11:49 AM
Thank you.
I missed that!

Cheers

Hugo

asitudela
07-21-2004, 06:29 PM
Why you living in Spain you don´t search the spanish web??


--------------------------------------------------------------
Por cierto porque siendo español no has buscado una página de mapas española?

Yo creo q tendré que hacerlo aunque será más adelante.

hsad10
07-22-2004, 06:13 AM
Hi asitudela,
I´ve searched and tested some map sites like mappy and michelin, but they calculate some parameters to reach the map. Of course, without their scripts it is too much difficult to get an exact result.
This is the main reason because I decided to use multimap.

By the way, I´m living in Spain but I´m argentine...

So, if you can use another option, please share it with all OR community. Thanks.

Regards,
Hugo

--------------------------------------------------------------------------

He buscado y testeado una cantidad de mapas interactivos. Pero la mayoría de ellos utilizan algoritmos propios para calcular latitud y longitud de la dirección que les pasas.
Por ello, se hace más que dificultoso usar un mapa español.
Si encuentras uno y lo logras hacer funcionar, por favor compártelo con la comunidad de OR.
Gracias y saludos,
Hugo

hsad10
07-22-2004, 07:25 AM
Well, after many trials, finally I reach a spanish map site that accepts external parameters.
So, replace in my prior mod these lines in style.php (near line # 278)

$mapquest_string = "strAddress=$mapquest_address&strLocation=$mapquest_city&strCP=$mapquest_zip";
echo "<a href=\"http://www.viamichelin.com/viamichelin/esp/dyn/controller/mapPerformPage?$mapquest_string\" target=\"_map\"><b>Ver Mapa del Area</b></a>";
} // end makeMapQuestMap

It will works with mappy very well and more accurate than the older mod.

Enjoy,
Hugo

--------------------------------------------------------------------------

Esta modificación en el mod anterior que he sugerido, permite lograr un mapa muy preciso y en español.
Solo hay que reemplazar las líneas que están arriba en style.php.
Espero que les sea útil.
Saludos,
Hugo

asitudela
07-22-2004, 02:54 PM
Estaba modificando el script que habías posteado, el de antes de modificarlo (el de mappy) porque me daba problemas pero bueno en cuanto he ido a revisarlo otra vez he dicho.. coño ha desapercido!!!! jajaja y luego he visto que habías modificado el mensaje...

Ahora he probado el nuevo y me dado cuenta que este mapa es perfecto es uno de los mejores de españa, porque sale hasta mi pueblo que tiene unos 3000 habitantes........


Eres el mejor Hugo !! el mejor mapa en castellano !!


FELICIDADES!!!!!!!

hsad10
07-22-2004, 04:03 PM
Me has hecho sonrojar!!!
Me alegro mucho que lo puedas utilizar.
Saludos,
Hugo

xony
11-06-2004, 06:03 PM
:rolleyes: Hola amigos, soy nuevo usando este sistema, y tengo una pregunta, yo estoy probando con la version 1.1.5b y aunque he realizado los cambios que comentais en esta pagina sobre los mapas en españa, yo no veo ninguna utilidad donde me deje ver mapas, ¿es la version? o estoy en un error.

Un saludo y gracias.

hsad10
11-06-2004, 07:20 PM
Hola Yoni,
Solo debes seguir las instrucciones que he posteado antes.
Reemplaza el archivo style.php (está en template\vertical menu) por el archivo que te adjunto y verás que funciona perfectamente.
Espero que te sea util. ;)
Saludos,
Hugo
:D

bernardo
04-18-2005, 06:17 AM
Genial hsad10, lo he probado y me funciona de maravilla, muchas gracias.

laurenced
11-09-2005, 05:56 PM
This doesn't work for me, all I get is the following link:

http://www.multimap.com/map/places.cgi?client=public&lang=&advanced=&db=ES&cname=Great+Britain&overviewmap=&addr2=&addr3=&pc=

..so none of the data seems to be being inserted into the link. Any idea why this might be?

ian_ok
11-10-2005, 05:38 AM
This doesn't work for me, all I get is the following link:

http://www.multimap.com/map/places.cgi?client=public&lang=&advanced=&db=ES&cname=Great+Britain&overviewmap=&addr2=&addr3=&pc=

..so none of the data seems to be being inserted into the link. Any idea why this might be?
This is what I use for maps in Spain:


http://www.viamichelin.com/viamichelin/gbr/dyn/controller/mapPerformPage?strAddress=&strLocation=<? renderSingleListingItemRaw($listingID, "town") ?>&strCP=cadiz&strCountry=844&x=24&y=10" target="_blank">Map of <? renderSingleListingItemRaw($listingID, "town") ?>

Quite easy to do on any map website as you test with a search for properties in a certain area with data you have from database and then use then copy that URL and replace database text with renderSinglelistingitemraw for that field.

Ian

laurenced
11-11-2005, 06:54 AM
This is what I use for maps in Spain:


http://www.viamichelin.com/viamichelin/gbr/dyn/controller/mapPerformPage?strAddress=&strLocation=<? renderSingleListingItemRaw($listingID, "town") ?>&strCP=cadiz&strCountry=844&x=24&y=10" target="_blank">Map of <? renderSingleListingItemRaw($listingID, "town") ?>

Quite easy to do on any map website as you test with a search for properties in a certain area with data you have from database and then use then copy that URL and replace database text with renderSinglelistingitemraw for that field.

Ian

That's quite elegant. I managed to get the other one to work, and it's good because it uses postcodes too (many of my client's properties are in the country) which is useful. At the moment most of his ~1000 properties have no postcodes attached to them (I only just added the postcode field) but Multimap is good in that it will show a map of just the town/area if there is no postcode in the URL, and if there is, then it will be more precise and go to that postcode.

I'll need to clean up the script to get rid of the address and city parts though, because the website won't be passing them to Multimap.

PS the original problem was in the script: there shouldn't be dollar signs ($) before the variable names in the first make_db_safe lines.