frasmar
04-30-2009, 07:38 AM
I'm planning a project and I'm a complete beginner so will be learning new skills to achieve this. I haven't started yet because I don't yet know which tools to use for the job. I think it comes down to a question of sharing data between Javascript and PHP.
What I want my web page to do (and the tools I think I should use) -
(1) Geocode a UK postcode using Google Maps API and display this on the map (Javascript/AJAX unless there's a PHP way).
(2) Extract the latitude and longitude of the chosen point on the map (javascript?)
(3) Convert to UK grid (could be either javascript or php, I already have a javascript example, but it's translatable. )
(4) Use that UK grid reference to query a database of historic wind values which has >1M records and is therefore, I think, way to big to be handled client side. (?) I have the database as a csv. I think the size of this database is the primary reason I can't do the whole thing in javascript and I don't think javascript is capable of querying a remote database (?). (php,mySQL)
(5) Use the wind value from the database to estimate the likely performance of a wind turbine at that location. This is a complicated calculation which involves some quasi-confidential business data, so it's preferable but not essential that it reside server-side. This is the secondary reason I'd rather not do it all in javascript. (php)
(6) Display predictions of wind turbine performance and income for the geocoded location. (php)
(7) Update those results if the marker on the google map is moved to a new location. (javascript to php again).
Now, by googling, I've found conflicting opinions as to whether it's possible to pass information from javascript to be dealt with by php. This is a potential stumbling block. I understand that the php code runs on the server and sends html or javascript output to the browser to render, so once that's done it's too late to use information obtained using javascript to the php logic. But I'm imagining there must be a way to force a refresh of the php using the latitude and longitude obtained from javascript?
Can I accomplish this with a cookie? Both javascript and php can read and write cookies, so can I bridge the divide this way?
Or should I be researching GET and POST methods for creating a new page?
Or should I be generating the javascript for the google map dynamically using php?
I'm a bit lost and would really appreciate some pointers before I start out along a path where the bridge is out. I'm a beginner, so I will not feel patronised by very simplistic "101" type explanations.
Is my project possible?
Many thanks.
Frasmar
What I want my web page to do (and the tools I think I should use) -
(1) Geocode a UK postcode using Google Maps API and display this on the map (Javascript/AJAX unless there's a PHP way).
(2) Extract the latitude and longitude of the chosen point on the map (javascript?)
(3) Convert to UK grid (could be either javascript or php, I already have a javascript example, but it's translatable. )
(4) Use that UK grid reference to query a database of historic wind values which has >1M records and is therefore, I think, way to big to be handled client side. (?) I have the database as a csv. I think the size of this database is the primary reason I can't do the whole thing in javascript and I don't think javascript is capable of querying a remote database (?). (php,mySQL)
(5) Use the wind value from the database to estimate the likely performance of a wind turbine at that location. This is a complicated calculation which involves some quasi-confidential business data, so it's preferable but not essential that it reside server-side. This is the secondary reason I'd rather not do it all in javascript. (php)
(6) Display predictions of wind turbine performance and income for the geocoded location. (php)
(7) Update those results if the marker on the google map is moved to a new location. (javascript to php again).
Now, by googling, I've found conflicting opinions as to whether it's possible to pass information from javascript to be dealt with by php. This is a potential stumbling block. I understand that the php code runs on the server and sends html or javascript output to the browser to render, so once that's done it's too late to use information obtained using javascript to the php logic. But I'm imagining there must be a way to force a refresh of the php using the latitude and longitude obtained from javascript?
Can I accomplish this with a cookie? Both javascript and php can read and write cookies, so can I bridge the divide this way?
Or should I be researching GET and POST methods for creating a new page?
Or should I be generating the javascript for the google map dynamically using php?
I'm a bit lost and would really appreciate some pointers before I start out along a path where the bridge is out. I'm a beginner, so I will not feel patronised by very simplistic "101" type explanations.
Is my project possible?
Many thanks.
Frasmar