PHP script to add Google maps pointer

Discussion in 'PHP' started by Kain, Jan 11, 2011.

  1. #1
    I'm looking for a php script that will allow users to add pointers to a google map them selves.

    I.E. When they log in, they get to click on a map to show their location and it is stored in a database and dynamically added to the map so all users can see the location.

    I'm looking for either
    • A free/cheap script
    • A Tutorial
    • A Joomla Extension might also do the trick

    Has anyone seen anything like this?

    Thanks
     
    Kain, Jan 11, 2011 IP
  2. kokulusilgi

    kokulusilgi Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    First step you must save users ip in your database.

    Secondly, you can some ip geo location api service. I.E. ipinfodb.com/ip_location_api_json.php or hostip.info/use.html

    And then you can put the location information on google maps api.

    <html>
        <head>
            <meta name="viewport" content="initial-scale=1.0, user-scalable=no"/>
            <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
            <title>
                96 Dundas Street, North Dunedin, Dunedin City, Otago, New Zealand            view on map</title>
            <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false">
            </script>
            <script type="text/javascript">
                
                var geocoder;
                
                var map;
                
                var query = "96 Dundas Street, North Dunedin, Dunedin City, Otago, New Zealand";
                
                function initialize(){
                
                    geocoder = new google.maps.Geocoder();
                    
                    var myOptions = {
                    
                        zoom: 8,
                        
                        mapTypeId: google.maps.MapTypeId.ROADMAP
                    
                    }
                    
                    map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
                    
                    codeAddress();
                    
                }
                
                
                
                function codeAddress(){
                
                    var address = query;
                    
                    if (geocoder) {
                    
                        geocoder.geocode({
                            'address': address
                        }, function(results, status){
                        
                            if (status == google.maps.GeocoderStatus.OK) {
                            
                                map.setCenter(results[0].geometry.location);
                                
                                var marker = new google.maps.Marker({
                                
                                    map: map,
                                    
                                    position: results[0].geometry.location
                                
                                });
                                
                            }
                            else {
                            
                                document.getElementById('map_canvas').innerHTML = '<h2>This location is not found on map.</h2>';
                                
                            }
                            
                        });
                        
                    }
                    
                }
                
            </script>
        </head>
    
        <body style="margin:0px; padding:0px;" onload="initialize()">
            <div id="map_canvas" style="width:100%; height:100%">
            </div>
        </body>
    </html>
    
    HTML:
     
    kokulusilgi, Jan 11, 2011 IP
  3. Kain

    Kain Peon

    Messages:
    58
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for your help.

    What I actually need is the ability for a user to enter multiple markers on a map (a few hundred), store the location markers in a database and have them displayed dynamically.

    Hope I'm making sense here.
     
    Kain, Jan 12, 2011 IP
  4. shelinauto

    shelinauto Peon

    Messages:
    110
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    thnx , m also gonna use it for my site..
    really thanx for sharing.
     
    shelinauto, Jan 13, 2011 IP
  5. joomlaserviceprovider

    joomlaserviceprovider Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    jLocator provides rich interface to search and display locations using Google Map API.Supports the feature of customized and diffrent markers for diffrent location and multiple views.

    jLocator provides easy to use interface for searching location, zip code, area code and provides Google map to display the locations.

    * Full Google Maps integration
    * Zip code/Postal code perimeter search
    * A plugin so you can display locations in articles
    * Includes a jLocator module
    * No need to enter LAT/LONG info
    And much much more...

    Check out jLocator here: joomlaserviceprovider.com/component/docman/doc_details/14-jlocator.html
     
    joomlaserviceprovider, Mar 20, 2012 IP