最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - Google maps api database interaction - Stack Overflow

programmeradmin1浏览0评论

I am currently working on a project where users need to be able to enter geological data (such as a certain street name) into a website which will be put into a database and then retrieved and displayed on a Google map for all users to see.

I've done a little research and so far it looks like the best way to do this is to use a PHP script for getting data and sending it to a MySQL database where it can then be retrieved by another PHP script and then passed to JavaScript to display on the map.

From a big picture, the standpoint is this the best way to do things?

Thanks in advance!

I am currently working on a project where users need to be able to enter geological data (such as a certain street name) into a website which will be put into a database and then retrieved and displayed on a Google map for all users to see.

I've done a little research and so far it looks like the best way to do this is to use a PHP script for getting data and sending it to a MySQL database where it can then be retrieved by another PHP script and then passed to JavaScript to display on the map.

From a big picture, the standpoint is this the best way to do things?

Thanks in advance!

Share Improve this question edited Sep 24, 2020 at 17:58 Alex 1,5801 gold badge15 silver badges27 bronze badges asked Feb 6, 2009 at 22:56 fauxCoderfauxCoder 3645 silver badges15 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

Looks like your problem has a few separate steps:

  1. Sign up for a Google Maps API key.

  2. Write something that lets the user input the address and save it in the database.
    2a. The same script should convert the address to a coordinate using Geocoding. The result should (must) be saved in the database as well since Google will only accept 15k Geocode queries per IP per day. Since you will be saving the results it would only be a problem if you are going to add more than 15k items to your map in one day.

  3. Write the script that generates the map. There may be some cool Google API calls, if not you will have to do do some work yourself. Cache the map with a timestamp so you can save some processor/time.

  4. Create an interface that will display the map, integrate with step 2a, and call step 3.

@Phil's response is good. Here are a few of my additions:

Google geocoding doesn't have to be done server side. The 15k limit counts against the client ip not the server ip. If it did, a single malicious client could use up the host site's limit and effectively DOS the site's geocoding features.

http://code.google./support/bin/answer.py?answer=93464&topic=12266

One reason to perform the geocoding server-side before storing the db result is it may make it easier to validate the user's entry to make sure the address they enter is, in fact, geocodable. In that case you are subject to a 15k query host limit. If you put the validation code on the client you spread the request out to all the clients.

There are some nifty Google API calls. A quick peek through the docs will reveal a straightforward process of:

  • Fetch the address from the db
  • Geocode it into a GPoint
  • Center the map on the GPoint
  • And possibly drop a marker on the GPoint

These types of things are covered in the docs pretty pletely.

http://code.google./apis/maps/documentation/examples/

Also, to directly answer your question. Yes, it looks like you are on the right track.

发布评论

评论列表(0)

  1. 暂无评论