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

How do I get the geo location data from an image using JavaScriptPHP? - Stack Overflow

programmeradmin4浏览0评论

I am making a custom Google Maps application. I'd like to display all of my iPhone images on the map and I'd like to retrieve the geo location data using JavaScript or PHP. Is this possible? If not, what other way can I get the data?

Thanks.

I am making a custom Google Maps application. I'd like to display all of my iPhone images on the map and I'd like to retrieve the geo location data using JavaScript or PHP. Is this possible? If not, what other way can I get the data?

Thanks.

Share Improve this question asked Jun 27, 2011 at 7:50 SabaiSabai 1,5996 gold badges26 silver badges40 bronze badges
Add a ment  | 

5 Answers 5

Reset to default 8

Geo data using JavaScript answer:

The accepted answer only answers the PHP question, but if you are dealing with a smartphone photo there is a good chance the image is going to be 3megs or more! so getting EXIF data client side is what you want.

There is an awesome jQuery plugin which I have used. Download the project and open the index.html for a demo, unment line 26 //console.log(exifObject); to see the object detail, you can get anything in the EXIF object, not just the Geodata: http://plugins.jquery./file-exif/

In PHP, you can do this by using EXIF Functions

Its possible if the geo-location data is stored in the image metadata. You can do it with PHP using the Exif functions.

Once you parse the longitude and latitude from inside of the image meta data, use the Google Maps api to display it. There are a bunch of ways of embedding it depending on how interactive and styled you want the map:

http://code.google./apis/maps/index.html

If you just want a flat image use the static maps api. Keep in mind there's a lot of stuff you can set including zoom level. Example:

http://maps.google./maps/api/staticmap?center=Brooklyn+Bridge,New+York,NY&zoom=14&size=512x512&maptype=roadmap&markers=color:blue|label:S|40.702147,-74.015794&markers=color:green|label:G|40.711614,-74.012318&markers=color:red|color:red|label:C|40.718217,-73.998284&sensor=false

This information is stored in the EXIF meta data in the image. In PHP you can read this data using the the exif_read_data() function.

发布评论

评论列表(0)

  1. 暂无评论