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 2 of 2
  1. #1
    New Coder
    Join Date
    Aug 2010
    Location
    myeik
    Posts
    81
    Thanks
    6
    Thanked 5 Times in 5 Posts

    how to combine the js code one using id & show two map?

    Code:
    jQuery(document).ready(function() {
     
      // Load google map
      var map = new google.maps.Map(document.getElementById('gmap'),  {
        center: new google.maps.LatLng(0,0),
        zoom: 3,
        mapTypeId: google.maps.MapTypeId.ROADMAP,
        panControl: false,
        streetViewControl: false,
        mapTypeControl: false
      });
    
      var map1 = new google.maps.Map(document.getElementById('gmap1'),  {
        center: new google.maps.LatLng(0,0),
        zoom: 3,
        mapTypeId: google.maps.MapTypeId.ROADMAP,
        panControl: false,
        streetViewControl: false,
        mapTypeControl: false
      });
      
    });
    it work but I want to one Object.

    This is the Full Source code

    Code:
    <!DOCTYPE HTML>
    
    <html>
    
    <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
      <title>Your Website</title>
      <script type="text/javascript" src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
      <script type="text/javascript">
     
    jQuery(document).ready(function() {
     
      // Load google map
      var map = new google.maps.Map(document.getElementById('gmap'),  {
        center: new google.maps.LatLng(0,0),
        zoom: 3,
        mapTypeId: google.maps.MapTypeId.ROADMAP,
        panControl: false,
        streetViewControl: false,
        mapTypeControl: false
      });
    
      var map1 = new google.maps.Map(document.getElementById('gmap1'),  {
        center: new google.maps.LatLng(0,0),
        zoom: 3,
        mapTypeId: google.maps.MapTypeId.ROADMAP,
        panControl: false,
        streetViewControl: false,
        mapTypeControl: false
      });
     
     
    
     
    });
    </script>
    </head>
    
    <body>
    
     
        
    
    
    
    
    <div style="padding-bottom:10px;"><input type="text" name="address" value="O. J. Brochs g 16a, Bergen" style="width:400px;border:1px solid black"><input type="button" name="search" value="Geocode"></div>
    <div id="coords"></div>
    <div id="gmap" style="width:370px; height:300px;"></div>
    
    <div style="padding-bottom:10px;"><input type="text" name="address" value="O. J. Brochs g 16a, Bergen" style="width:400px;border:1px solid black"><input type="button" name="search" value="Geocode"></div>
    <div id="coords"></div>
    <div id="gmap1" style="width:370px; height:300px;"></div>
    
    
    
    
    <script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script>
    </body>
    
    </html>

  • #2
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,989
    Thanks
    56
    Thanked 557 Times in 554 Posts
    I'm not sure that I really understand, but maybe something like this:
    Code:
     var opts ={
     center: new google.maps.LatLng(0,0),
        zoom: 3,
        mapTypeId: google.maps.MapTypeId.ROADMAP,
        panControl: false,
        streetViewControl: false,
        mapTypeControl: false
     }
    
    
     // Load google map
      var map = new google.maps.Map(document.getElementById('gmap'),  opts);
    
      var map1 = new google.maps.Map(document.getElementById('gmap1'), opts);
    (absolutely no need for jQuery from the code you have shown, btw...)


  •  

    Tags for this Thread

    Posting Permissions

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