473,385 Members | 1,740 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to add multiple pinpoints on Google maps from mysql database using PHP?

194 100+
Hi everyone,

I am trying to add multiple pinpoint to google map using Lon/Lat. All addresses will be fetched from mysql database using PHP.

I have looked at google and searched for it on various sites but nothing helpful i found.

i have used the following code which worked for only one address whereas i have alot of addresses.

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta name="viewport" content="initial-scale=1.0, user-scalable=no"/>
  5. <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
  6. <title>Google Maps JavaScript API v3 Example: Geocoding Simple</title>
  7. <link href="http://code.google.com/apis/maps/documentation/javascript/examples/standard.css" rel="stylesheet" type="text/css" />
  8. <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
  9. <script type="text/javascript">
  10.   var geocoder;
  11.   var map;
  12.   function initialize() {
  13.     geocoder = new google.maps.Geocoder();
  14.     var latlng = new google.maps.LatLng(-34.397, 150.644);
  15.     var myOptions = {
  16.       zoom: 8,
  17.       center: latlng,
  18.       mapTypeId: google.maps.MapTypeId.ROADMAP
  19.     }
  20.     map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
  21.   }
  22.  
  23.   function codeAddress() {
  24.     var address = 'Sydney, NSW';
  25.     geocoder.geocode( { 'address': address}, function(results, status) {
  26.       if (status == google.maps.GeocoderStatus.OK) {
  27.           initialize();
  28.         map.setCenter(results[0].geometry.location);
  29. /*        var marker = new google.maps.Marker({
  30.             map: map, 
  31.             position: results[0].geometry.location
  32.         });*/
  33.  
  34.         var marker = new google.maps.Marker({
  35.   position: new google.maps.LatLng+results[0].geometry.location, 
  36.   map: map, 
  37.               position: results[0].geometry.location,
  38.   title:"Hello World!"});  
  39.       } else {
  40.         alert("Geocode was not successful for the following reason: " + status);
  41.       }
  42.     });
  43.   }
  44. </script>
  45. </head>
  46. <body onload="initialize();codeAddress();">
  47.  
  48. <div id="map_canvas" style="height:90%"></div>
  49. </body>
  50. </html>
  51.  
Please tell me how i can add multiple pin points to google map. I dont wana use static map.

Thanking you.

Faisal
Jan 17 '11 #1
6 16133
JKing
1,206 Expert 1GB
Is it that you don't know how to write the php code to loop through your points and plot several markers or that you are being restricted by the google api to only one marker?
Jan 18 '11 #2
mfaisalwarraich
194 100+
second one is my problem i.e. restricted by the google api to only one marker. cuz addresses will be in database and i know how to loop through them, but this google api is allowing only one address to be marked. please guide me how i can add multiple markers?
Jan 18 '11 #3
JKing
1,206 Expert 1GB
You add another marker the same way you added the first one.
Expand|Select|Wrap|Line Numbers
  1. var marker = new google.maps.Marker({
  2.   position: new google.maps.LatLng+results[0].geometry.location, 
  3.   map: map, 
  4.               position: results[0].geometry.location,
  5.   title:"Hello World!"});  
  6.  
Swap out the position for a new one.
Jan 18 '11 #4
mfaisalwarraich
194 100+
i added first market by providing lat/lng values using street address. as i already mentioned addresses are stored into the database. this API is allowing to run only once. as when i tried to run it under PHP/MySQL query its giving me error of "Over Query Limit". Markers will be added using lat/lng values here im confused what is the best way to do it.

Which Google Map API will give me the solution for it?
Jan 19 '11 #5
JKing
1,206 Expert 1GB
I'm sorry I really don't know the ins and outs of the Google Maps API. This question isn't PHP specific either.

Now you never mentioned the "Over Query Limit" at the start of all this. I googled it and there is a limit to how many requests you can make using the geocoding API.

I suggest you read this : http://code.google.com/apis/maps/doc...ion/geocoding/
Jan 19 '11 #6
mfaisalwarraich
194 100+
im sorry too :). I think i got the solution with a class available at phpclasses. but still i have some issue which i already have posted at this forum "How to insert an array into an array?".

thank you.
Jan 19 '11 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Jeff Sandler | last post by:
I have a database I created in mySQL. I've been entering data every day into the database using a Java application that I wrote. The database and the Java program are on the same Win 98 SE...
11
by: menmysql | last post by:
i am getting the following error while connecting mysql database using jsp java.sql.SQLException: Communication link failure: Bad handshake can any one tell what is the actual problem
8
by: menmysql | last post by:
i am not bale to solve this problem since two weeks i am trying to access records from mysql database using jsp. inside this jsp program i wrote all my JDBC code. it is working very nicely and...
9
by: christopher_board | last post by:
Hi all. I am trying to connect to a MySQL Database using PHP on a local machine using locahost. I am using the following code <?php $dbhost = 'localhost'; $dbuser = 'root'; $dbpass =...
2
by: zalina | last post by:
hai..does anyone have example how to connect to mysql database using c++ language?
3
by: Suresh P | last post by:
Hi All, I tried to access the mysql database in ODBC using ip address and username/password. It returns, "cannot connect to MySQL server on IP ADDRESS(10060)". This could be related to Firewall...
2
by: maheshonmail | last post by:
i want to store pictures in mysql database using php code/ so please send me the most efficient code for doing this.
1
by: nadeenahmed | last post by:
I have Connected to a MySQL Database using a neatbeans editor. Now, I want to use that same database I created earlier on another pc. Can anyone help and tell me how that is done, please? Thank...
1
by: twinkle2010 | last post by:
Hi I am a new web programmer.I got an issue that reads the excel sheet data and store it to MYSQL database using php. I dont have any idea on that. can you help me?
2
by: Nilanjan Sanyal | last post by:
how to retrieve hindi text from mysql database using php
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.