1 Replies - 1170 Views - Last Post: 13 March 2013 - 05:20 PM

#1 theplan   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 21-February 13

User generated JSON on to a Google Map

Posted 12 March 2013 - 04:04 PM

I'm not sure if it's the time of night, or whether what I'm doing is a little bit difficult, but I've come here for some help (hopefully).

On my site, users are provided with a form to fill in then a php script will query the database and retrieve and display the results in JSON. This all works fine, no problems here. What I am trying to do with the resulting JSON is either re-initialize the Google Map with the JSON results, or, if easier, reload the entire page with the map updated with the JSON results.

I think the problem is just with my logic, and how things are happening. At the moment:
- user fills fields (species/dates/location etc)
- user clicks submit
- userquery.php is ran which queries according to the fields
- userquery.php displays results as JSON

whether this is the right order, or whether I'm doing things right I'm not sure.

I have been able to display the results of the entire database no problem, but of course this occurs when the page is loaded and the query is a SELECT * FROM as oppose to a user generated one. The query.php file is ran by the map JS file, which takes the results and plots them on the map, but of course userquery.php is different every time it is ran so cant be used like this.

Sorry if I'm rambling/dont make sense, its late, ive been working all day/night so I'll answer any Qs you might have, but any ideas?


Is This A Good Question/Topic? 0
  • +

Replies To: User generated JSON on to a Google Map

#2 Takk   User is offline

  • D.I.C Head

Reputation: 40
  • View blog
  • Posts: 111
  • Joined: 08-March 13

Re: User generated JSON on to a Google Map

Posted 13 March 2013 - 05:20 PM

Sometimes rested eyes will help a ton. I'm not sure where your problem is coming up exactly, the returned json should be parsed and used to plot the coordinates on the map. If userquery.php is being called to gather JSON, it should be going only that..

For instance, your user would visit mysite.php, enter information and hit submit.

The submit button should likely be tied to a javascript function which will request the json data from userquery.php, and then plot on the map.

I'm not sure of your specific question in this case, but you should be interpreting JSON data alone. Whether you grab it using php at the beginning of the file and use php to plot to the map, or whether you use javascript to perform an AJAX like call and plot that way.

The data you are interpreting should be different, but in the same format every time, lending it well to being parsed in either JS or PHP and plotted.

Read your post and clarify a bit once you've gotten some sleep and maybe we can offer a little more help. But bottom line is, if you have properly created your JSON data, and you know how to plot the coords to the map, this is how this needs to be done, you shouldn't be getting much 'different information' thats making it hard to work with.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1