ASPX templates
Version 4.x > ASPX templates > Creating custom SQL within Google Maps. View modes: 
User avatar
Member
Member
BC - 12/15/2009 10:12:42 PM
   
Creating custom SQL within Google Maps.
I am in the process of using google maps web part in a project. I've been able to create the google map with no problem. I'm now trying to connect a custom table i've built to show the latitude and longitude on the google map. I've built a query that is in the custom table properties and this works.

Now i'm trying to build a custom query with custom code in my code behind. The issue I am having is the query does not include my custom part.

I'm using the following code.

this.GoogleMaps1.WhereCondition = "Latitude >= 39.144554 and Latitude <= 43.144554) ";
this.GoogleMaps1.ReloadData();

The system is only running the query in the custom table. I was looking for the statement above to append to current where close in the custom table query. I've also tried using the ##where## and that does not work.

any ideas...thanks.

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 12/17/2009 1:25:37 AM
   
RE:Creating custom SQL within Google Maps.
Hi,


If I am getting the right meaning, the "Latitude" values are from your custom table. If yes, you need to load the values from your custom table to some variables and then you can use them in the where condition.

Or, second option is to add the columns you want to use to View_CMS_Tree_Joined view so they will be used in Where condition - in general, all web parts are using for ORDER BY and WHERE conditions this view.

Best Regards,
Juraj Ondrus

User avatar
Member
Member
BC - 12/18/2009 5:38:21 AM
   
RE:Creating custom SQL within Google Maps.
What approach would you recommend if I said I’m querying through a 24,000 address database. My results are pulling back a subset of some 3,000. Then the logic will narrow down to around 500 or so. There are tree variables that are dynamic.

Users starting latitude and longitude
List of latitude and longitude from custom table
Distance user would like to look out.

My custom table query has the following SQL.

SELECT itemid, Name, Address, City, State, Zip, Latitude, Longitude,

RADIANS(SQRT(power((41.144554 - Latitude),2) + power((-81.894109 - Longitude),2))) * (7912/2) as Miles

FROM customtable_kb_Facilities

where RADIANS(SQRT(power((41.144554 - Latitude),2) + power((-81.894109 - Longitude),2))) * (7912/2) < 50

order by Miles


In the code behind I’m using.

this.GoogleMaps1.WhereCondition = "(Latitude >= 39.144554 and Latitude <= 43.144554) and (Longitude >= -83.894109 and Longitude <= -79.894109)";
this.GoogleMaps1.ReloadData();

My goal is to setup some type of variable such as @Latitude that I can pass value to in the cutom table query. From your answer I’m thinking view_CMS_Tree_joined is the best aproach. Would I have to create a new doucment through the interface for all my 24,000 locations, or can I just insert them?

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 12/21/2009 2:41:45 AM
   
RE:Creating custom SQL within Google Maps.
Hi,

The problem here is that the google maps web part is intended to work with documents and their fields - so you will need to create the documents and then use the view as I mentioned or to modify the google map web part so it will work with the result returned from your table using your SQL query.

Best Regards,
Juraj Ondrus