Get current map in event handler of marker click or position changed

Sometimes, we need to used map to get its current zoom level or center coordinates in event handlers. We can easily use map variable which we have created to show map through google map javascript api, but problem occurs when there are multiple map presents on the page, then in event handler we cannot use just map variable, to identify that  the event handler is fired for which map, so we need to use extra function to get map in event handler of google map javascript api.

Google Map API has a function get(‘map’) which can be used to get current map. I have shown here two examples below which shows how to use this function : Keep on reading

Create multiple custom controls dynamically in Google Map API

If we want to create google map javascript api’s custom control then we can find the solution in developer guide of google map api but if we want to create custom control dynamically by sending its html and position in PHP then, we did not find its solution easily. I have created the custom control dynamically using javascript and PHP, so I am posting my content here, so anyone can get help. My code is here :

//Define custom control html and position here
//Here I am creating more than one custom control
$custom_control_html = array(
0 => array(‘html’=>’Control 1’, ‘position’=>’TOP_LEFT’),
1=> array(‘html’=>’Control 2’, ‘position’=>’TOP_CENTER’)
?> Keep on reading

Geocoding & Reverse Geocoding in Google Map Javascript API

Geocoding is a technique of Google Map API which is used to get complete information about an address like its geographic coordinates (latitude, longitude), its city, state, postal_code, country etc. In javascript, we can just simply use below code to get geographic coordinates of any location :

<script type=”text/javascript”>
var geocoder_obj = new google.maps.Geocoder(); Keep on reading

How to use Google Map Geocoding API in PHP

Google Map API has geocoding technique from which we can get information about latitude/longitude, complete address information like region, city, country etc.. of any address. We can also perform reverse geocoding by passing the latitude and longitude of a place and then can get its address and other additional information. Sometimes, we may need to use google map api in  PHP instead of javascript.

So, whenever you need to use Google Map API’s geocoding service, you can use it by sending request to this url{your_address}&key={#YOUR_API_KEY} using curl method of PHP as : Keep on reading

Javascript Google Map API : Change the content of infowindow using AJAX

Its an interesting subject that how one can change the content of google map’s infowindow dynamically. Many times we need to perform an action which results in change of content of infowindow also.

For example, if we have displayed a like button for a particular place which is showing in the content, and its marker is also showing in map. On clicking on that marker, infowindow will launch. Infowindow will also have the same like button. If user clicks on like button of place which is showing in content then we may need to change the style or text of infowindow’s like button also, whenever infowindow will be launched, to show that it is liked now. Keep on reading