Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script type="text/javascript">
- var geocoder;
- var map;
- // create map objects
- function initialize(address)
- {
- geocoder = new google.maps.Geocoder();
- var latlng = new google.maps.LatLng(
- 56.9349327,-4.245415299999991);
- var myOptions =
- {
- zoom: 5,
- center: latlng,
- mapTypeId: google.maps.MapTypeId.ROADMAP
- }
- map = new google.maps.Map(document.getElementById("map_canvas"),
- myOptions);
- <?php
- require('connection.php');
- $result = mysqli_query($con,"SELECT * FROM `customers`") or
- die ("Error: ".mysqli_error($con));
- $yourArray = array();
- $index = 0;
- ?>
- <?php
- //Starts while loop so all addresses for the given information
- //will
- //be populated.
- while($row = mysqli_fetch_assoc($result))
- //instantiates array
- {
- ?>
- var address = "<?php echo $row['CustomerAddress'] ?>";
- 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
- });
- var contentString = '<div id="content">'+
- '<div id="siteNotice">'+
- '</div>'+
- '<b>Customer Name :<?php echo $row['CustomerName']?>
- </b>'
- +'<br>'+
- '<b> Customer Address : <?php echo $address ?> </b>'+'<br>'+
- '<b> Customer ID : <?php echo $row['ID'] ?> </b> '
- '</div>';
- var infowindow = new google.maps.InfoWindow({
- content: contentString
- });
- google.maps.event.addListener(marker, 'click', function() {
- infowindow.open(map,marker);
- });
- }
- });
- <?php
- $address++;
- } //ends while
- ?>
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement