Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Jan 2013
    Posts
    74
    Thanks
    19
    Thanked 1 Time in 1 Post

    Adding Dynamic Map To Website

    I'm looking to add a simple map to a website which will load in locations from a database. The locations will be from around the country.

    I've spent the past hour looking at pages and pages of Google documentation but I can't seem to find what I'm looking for. It's either way too complex or way too simple.

    I do have code to generate a Google map with one location, just not many locations.

    Anyone have any tips on where to find something like this?

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,471
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    Can you give us an example of a map you would like to see?
    There are many variations to what you're looking for.

  • #3
    New Coder
    Join Date
    Jan 2013
    Posts
    74
    Thanks
    19
    Thanked 1 Time in 1 Post
    Quote Originally Posted by mlseim View Post
    Can you give us an example of a map you would like to see?
    There are many variations to what you're looking for.
    Off the top of my head I'm thinking like Google Places where it shows the map with the various locations pinned. But it can be simpler than that if it's even possible to be simpler than that.

  • #4
    New Coder
    Join Date
    Nov 2012
    Location
    chennai
    Posts
    14
    Thanks
    0
    Thanked 1 Time in 1 Post

    this site can help you


  • Users who have thanked rashgang for this post:

    cgdtalent (04-07-2013)

  • #5
    Regular Coder Arcticwarrio's Avatar
    Join Date
    May 2012
    Location
    UK
    Posts
    721
    Thanks
    20
    Thanked 84 Times in 84 Posts
    i use this:

    location.php?lat=53.478444&lon=-2.243958&acc=100

    to omit the circle overlay set acc to 0

    location.php?lat=53.478444&lon=-2.243958&acc=0

    lat long and meters of accuracy

    location.php
    PHP Code:
    <!DOCTYPE html>
    <html>
      <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <title>Circle Overlay</title>

        <style type="text/css">
          #map {
            width: 800px;
            height: 500px;
          }
        </style>

        <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>

        <script type="text/javascript">
          /**
           * Called on the initial page load.
           */
          function init() {
            var mapCenter = new google.maps.LatLng(<?php echo $_GET['lat']; ?><?php echo $_GET['lon']; ?>);
            var map = new google.maps.Map(document.getElementById('map'), {
              'zoom': 14,
              'center': mapCenter,
              'mapTypeId': google.maps.MapTypeId.ROADMAP
            });

            // Create a draggable marker which will later on be binded to a
            // Circle overlay.
            var marker = new google.maps.Marker({
              map: map,
              position: new google.maps.LatLng(<?php echo $_GET['lat']; ?><?php echo $_GET['lon']; ?>),
              draggable: true,
              title: 'Drag me!'
            });

            // Add a Circle overlay to the map.
            var circle = new google.maps.Circle({
              map: map,
              radius: <?php echo $_GET['acc']; ?> // 3000 km
            });
            circle.bindTo('center', marker, 'position');
          }
          
          // Register an event listener to fire when the page finishes loading.
          google.maps.event.addDomListener(window, 'load', init);
        </script>
      </head>
      <body>
        <h1></h1>
        <div id="map"></div>
      </body>
    </html>
    Last edited by Arcticwarrio; 04-05-2013 at 01:52 PM.
    There are 10 types of people on CodingForums,
    Those who understand Binary and those who dont.
    Get Cloud Hosting now from only£59 / month

  • Users who have thanked Arcticwarrio for this post:

    cgdtalent (04-07-2013)

  • #6
    New Coder
    Join Date
    Jan 2013
    Posts
    74
    Thanks
    19
    Thanked 1 Time in 1 Post
    Much thanks to rashgang and Articwarrio! I was able to come up with something using both sets of info and then I found something on geocoding so I could convert the standard addresses into lat and lng coordinates.

    Thanks again!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •