A bit of background: I’m creating a google map that places markers via PHP/Javascript. These markers are brought in from a MYSQL table and placed using their latitude and longitude. I followed a Google tutorial on how to do this and it’s working fine. The way it does this is a PHP file (called genxml.php) creates a XML for JS to read and the dynamically place on the map. All good. Now here the problem comes in.
Obviously, a whole heaps of markers on a map isn’t a huge lot of good, well because they are just markers. Yes ok, they have labels (when you click on them) but trying to find a particular marker is not easy - there are around 2000 of them.
So after studying the JS code a bit, I noticed that the center of the map is set via a lng & lat in the JS. So I added some PHP into it with GET, and so the url became something like this map.php?lng=55.2&lat=-1.2
What I want to do (and am stuck on) is create a search box, that suggests names (from the relevant column in MYSQL) and when you click on them, the a
tag is set something like this: <a href="?lng=$lng&lat=$lat">
with the $lng and the $lat obviously filled out by the numbers.
I followed this tutorial (http://www.w3schools.com/php/php_ajax_livesearch.asp) which searches an XML file, but when I reference with PHP file (which if you open it in a browser shows a XML file) it doesn’t work.
So if anyone could help me with this it would be great
A few points to help:
The PHP file is brought in like this:
downloadUrl("genxml.php", function(data) {
var xml = data.responseXML;
var markers = xml.documentElement.getElementsByTagName("marker");
genxml.php
says this, but works fine (I believe it’s just I haven’t escaped & and / etc)
This page contains the following errors:
error on line 1 at column 3427: Encoding error
Below is a rendering of the page up to the first error.`
The format of the XML file is the following:
<markers>
<marker name="" address="" lat="" lng="" type=""/>
</markers>`
I am indefinably not a PHP power user so lil bits of code with any explanations would be great
Any other info needed pls lmk
Thanks in advance