JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 3rd, 2012, 02:33 AM
helenp helenp is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Location: Marbella, Spain
Posts: 383 helenp Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 6 Days 8 h 41 m 34 sec
Reputation Power: 0
Google maps, 3 maps on same page

Hi,
I have google maps on my site 2v, however I need to use https: so I am trying to change to v3.
I found out how to do the map, however I cant manage to get more than one on same page.
This is one map, I need 3 of those, all with diferent maps locations,
any ideas?

Code:
    <script type="text/javascript" src="https://maps.google.com/maps/api/js?sensor=false"></script>
     
    <div id="map_canvas" style="width: 580px; height: 400px"></div>
     
    <script type="text/javascript">
    //<![CDATA[
    var map = null;
    function initialize() {
      var myOptions = {
        zoom: 13,
        center: new google.maps.LatLng(36.51308543049258, -4.886341094970703),
        mapTypeControl: true,
        mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU},
        navigationControl: true,
        mapTypeId: google.maps.MapTypeId.ROADMAP
      }
      map = new google.maps.Map(document.getElementById("map_canvas"),
                                    myOptions);
     
      google.maps.event.addListener(map, 'click', function() {
            infowindow.close();
            });
     
      // Add markers to the map
      // Set up three markers with info windows
     
           
          var point = new google.maps.LatLng(36.50856685143835, -4.866085052490234);
          var marker = createMarker(point,'<div style="width:240px">Text here <a href="link here">Link<\/a><\/div>')
         
         
           var point = new google.maps.LatLng(36.509653404078676, -4.91289496421814);
          var marker = createMarker(point,'<div style="width:240px"Text here <a href="link here">Link<\/a><\/div>')
         
         
            var point = new google.maps.LatLng(36.508601,-4.875945);
          var marker = createMarker(point,'<div style="width:240px">Text here<a href="link here">Link<\/a><\/div>')      
         
    }
     
    var infowindow = new google.maps.InfoWindow(
      {
        size: new google.maps.Size(150,50)
      });
       
    function createMarker(latlng, html) {
        var contentString = html;
        var marker = new google.maps.Marker({
            position: latlng,
            map: map,
            zIndex: Math.round(latlng.lat()*-100000)<<5
            });
     
        google.maps.event.addListener(marker, 'click', function() {
            infowindow.setContent(contentString);
            infowindow.open(map,marker);
            });
    }
     
    </script>

 

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > Google maps, 3 maps on same page

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap