Google Maps Javascript and PHP

I try to make a menu bar with icons which show the same icons in the map when clicked, for example hotels or bars.

I made a form with radio buttons for choose and click submit. This goes to PHP, connects to PostgreSQL, executes the query, and returns a result. It is not good solution though, because I want the user click on a icon to dynamically show the icons in map without any need to click on a submit button.

Is it possible, does an example exist?

I try to make it with jQueries and AJAX i make a jQuery which if i click show a alert massage i try to put the AJAX conection to return the JSONarray but is not make anythin This is a snapshot of php and javascript code. PHP conectin database make fetch

insert data in array with this line of code if($type=="warning"){ while ($row = pg_fetch_array($result,null, PGSQL_ASSOC)) { $row_array['gid'] = $row['gid']; $row_array['cause'] = $row['cause']; $row_array['duration'] = $row['duration']; $row_array['image'] = $row['image']; $row_array['km'] = $row['km']; $row_array['coords'] = json_decode($row['geom'], true); array_push($json_response,$row_array); } } echo $json_response;

JavaScript code

$(document).ready(function(){ $(".warning").click(function(event){ $.ajax({ url: 'php/ajax-follow.php', type: 'post', data: {'type': 'warning'}, dataType: 'json', success: function(data) { imgAr = JSON.parse($json_response); alert(imgAr); }, error: function(xhr, desc, err) { console.log(xhr); console.log("Details: " + desc + "
Error:" + err); } }); }); });

You could issue a AJAX request to your PHP service. In Javascript, add an event listener to your radio buttons that listens for change events. In the listener, issue the AJAX request to your PHP service. Handle the response of the PHP server in the AJAX callback and update your map.

How to convert address (as text) to gps coordinates?

The process is called of converting address to geographic coordinates is called geocoding.

Depending on how you'll be using the data, there's an API available from Google, details here. Good luck!

It really doesn't mather which framework you use, cause if you want something big you can have a big surprise: a limit of 2.5 K request /day this in case you don't store those info in a xml for later use. So at this moment you can find a better way to combine this with a OSM feature for localization.

check this google map api 3 service this is the reverse-geocoding service in google map api

Below is the code I use. I've prepared it basing on voncox code (thanks). Just didn't want to use Zend.
If you need to geocode multiple addresses just close this code with any kind of loop but probably there is faster way. I've used it only for about 100 addresses and it took about 30 seconds to process.

If you are able/willing to use php and Zend Framework then most of the Google Maps API is abstracted by using Zend_Http_Client.

FYI, MapQuest's Community License has an 'open' api, which uses nominatim / OpenStreetMap on the backside.

It is the same API (interface-wise) as the Community 'Licensed' api, which makes it easy to transition later.

I found that the open version requires the address to be a little too exact on the first day after deployment we "missed" several addresses. We thought the service was down, but it turns out the street names were missing little details such as a direction (ex SW).

Tried out the Licensed version, and it returned even the misspelled addresses.

The Community license licensed data version is free also, but are restricted by pretty much the same terms as the Google one. The 'open' data you can do with what you want.

If you are going to end up paying, then Yahoo's Boss/Geo api seems to be the cheapest for low volume they just don't have a free version.

If you use the Geolocation API, it would be as simple as using the following code.

You may also be able to use Google's Client Location API.

To give a bit more specific answer. HTML5 allows you to get the geo coordinates, and it does a pretty decent job. Overall the browser support for geolocation is pretty good, all major browsers except ie7 and ie8 (and opera mini). IE9 does the job but is the worst performer. Checkout

Also you need the approval of your user to access their location, so make sure you check for this and give some decent instructions in case it's turned off. Especially for Iphone turning permissions on for Safari is a bit cumbersome.

In the following Javascript I have defined a callback function for getting the Google Map resource. I specified the name of the callback while accessing Google Map Javascript API with the reference of the API key.

In this script, I have also created a function to get the current location on clicking the “My Current Location” button in the UI. This function creates content to be shown in the information window to show the latitude and longitude co-ordinates of the current Location.

Several of the map controls are configurable.

The controls can be modified by specifying control options fields.

For example, options for modifying a Zoom control are specified in the zoomControlOptions field. The zoomControlOptions field may contain:

  • google.maps.ZoomControlStyle.SMALL - displays a mini-zoom control (only + and - buttons)
  • google.maps.ZoomControlStyle.LARGE - displays the standard zoom slider control
  • google.maps.ZoomControlStyle.DEFAULT - picks the best zoom control based on device and map size


Note: If you modify a control, always enable the control first (set it to true).

Another configurable control is the MapType control.

Options for modifying a control are specified in the mapTypeControlOptions field. The mapTypeControlOptions field may contain::


At first, we will retrieve the visitor’s latitude and longitude using HTML5 Geolocation API. After that, we will send this latitude and longitude to the getLocation.php file using jQuery Ajax to get the visitor’s address. Once the response is received from the getLocation.php file, the visitor’s location will be displayed in the specified area ( #location ).

JavaScript Code:
The jQuery Ajax is used to post the latitude and longitude to PHP file. So, include the jQuery library first.

The getCurrentPosition() method is used to get the visitor’s position and showLocation() method is used to getting the visitor’s address from the getLocation.php file using Ajax.

HTML Code:
After getting the visitor position, the address will be shown on the web page ( #location span).

What is my location?

We opted to center the map on your current location when possible, using the html5 geolocation feature to find out the latitude and longitude of your location. When available, you can also get your location address.
Where am I? Your location coordinates are provided by your browser, and we can't access them without your consent. We do not keep any record of the location of our users, so feel free to allow the geolocation feature if you find it convenient. Visit this page to track my location.
If you don't share your location, the map will just be centered on a default GPS location.

Google Maps Driving Directions

Get Driving Directions with Google Maps for any mode of transportation: driving, bicycling, transit or walking.

Satellite view

Simply click on the "Satellite" button on the map to switch to the Map Satellite view of the chosen GPS location.

Name your GPS Coordinates!

You can name any place you bookmarked and make them available through our API.

Create a free account to bookmark your favorite places. Once logged in, just click on the star inside the infowindow on the map to add the point to your bookmark list (you can find it under the map on any page).
This is especially useful if you look for specific places on a device like your desktop, in order to use them later on with your mobile or your tablet. Just login and your points of interest will be available on all your devices (and on all the pages).

Customize your Google Maps

You can create links to custom maps to share with your friends or customers. Try it now.

Get Latitude and Longitude

At first, you need to get the latitude and longitude of your desired location. Follow the below steps to get the latitude & longitude from the Google Map.

  • Visit the Google Maps website.
  • Enter your desired location and search.

Copy this latitude and longitude for later use in the script.

Stripe Subscription Payment Integration in CodeIgniter

The Stripe Plans and Subscription API allows you to integrate recurring payment functionality in a quick and effective manner. Stripe Subscription is the powerful option to allow your website's members to purchase/subscribe membership online using their credit card. In the Stripe subscription payment system, the subscriber charged recurringly based on the specific interval. The subscriber can purchase a membership plan of your website with their credit card using Stripe API.

Comments For This Page

Need to show on maps the true locations of the true elevation points.
display /- 10meters

It's now showing see level to be - 1,54.96224225603763,-361.53869819623657,-9999.000,-32805.118
That's -9999.000m below sea level and that is measuring a point on the River Tyne at sea level!!
I think you have something wrong somewhere!

30 out of 599 comments shown. See all comments.

Add your own comment below and let others know what you think: