473,549 Members | 2,644 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

194 New Member
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 16161
JKing
1,206 Recognized Expert Top Contributor
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 New Member
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 Recognized Expert Top Contributor
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 New Member
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 Recognized Expert Top Contributor
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 New Member
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
4126
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 machine. I've been working on another program (an applet) to send and receive data over the internet. I got the applet to connect with the database and...
11
5218
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
4627
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 displaying records. now i wrote all the JDBC code in .java and i am accessing that code in jsp file. but this time i am getting only exceptions not...
9
3169
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 = 'password'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
2
2227
by: zalina | last post by:
hai..does anyone have example how to connect to mysql database using c++ language?
3
5213
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 on the server. Is there anyway to access MySQL database using ODBC without opening port 3306?
2
2056
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
6718
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 you.
1
4156
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
4797
by: Nilanjan Sanyal | last post by:
how to retrieve hindi text from mysql database using php
0
7462
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7492
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7823
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6059
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5381
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5101
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3491
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1069
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
777
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.