Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9009243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:08:18+00:00 2026-06-16T02:08:18+00:00

I’ve seen discussions on this topic on this site, and I’ve followed the proposed

  • 0

I’ve seen discussions on this topic on this site, and I’ve followed the proposed codes as closely as possible without luck. Can anyone tell me if the following code has any chance of being fixed, or if it’s breaking a fundamental Google law? What it’s trying to do is use one array of rectangles for two maps on the same page using the same geolocation code to position the marker representing the user’s location. I have provided 2 sets of options as the zoom, center and functionality of the two maps are different (as is the size of the div in which each is displayed). The first map is zoomed to street level with the user’s position in the center; the second is a wide view centered so as to show the full extent of the rectangle layer with the user’s location wherever it happens to be on the map. This is a bit more complicated than the examples I’ve seen, so maybe it can’t work and I just have to have two completely separate blocks of code. It would be a shame though to have to repeat the full rectangle array code…

Thanks for any suggestions.

<script src="http://maps.google.com/maps/api/js?sensor=false">
</script><script type="text/javascript">
if (navigator.geolocation) {navigator.geolocation.getCurrentPosition(function(position){
    var latitude = position.coords.latitude;
    var longitude = position.coords.longitude;
    var coords = new google.maps.LatLng(latitude, longitude);
    var map,map2;
    var mapOptions1 = {
        zoom: 16,
        center: coords,
        draggable: false, 
        zoomControl: false, 
        scrollwheel: false, 
        disableDoubleClickZoom: true,
        mapTypeId: google.maps.MapTypeId.ROADMAP
        };
    var mapOptions2 = {
        zoom: 5,
        center: new google.maps.LatLng(0, 0),
        mapTypeControl: true,
        mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        map = new google.maps.Map(document.getElementById("mapContainer1"), mapOptions1);
        map2 = new google.maps.Map(document.getElementById("mapContainer2"), mapOptions2);
 var marker = new google.maps.Marker({
                position: coords,
                map: map,map2

                           });
 marker.setIcon('sites/default/files/YourLocation_0.png')
 var rectangles = [];

rectangles[0]=new google.maps.Rectangle({
bounds:new google.maps.LatLngBounds(new google.maps.LatLng(a,b),new google.maps.LatLng(x, y)),
map:map,map2,
fillOpacity: 0,
strokeOpacity: 0,
url: 'http://example.com',
clickable: true
});
rectangles[1]=new google.maps.Rectangle({
bounds:new google.maps.LatLngBounds(new google.maps.LatLng(aa, bb),new google.maps.LatLng(xx, yy)),
map:map,map2,
fillOpacity: 0,
strokeOpacity: 0,
url: 'http://example2.com',
clickable: true
});
rectangles[2]=new google.maps.Rectangle({
bounds:new google.maps.LatLngBounds(new google.maps.LatLng(aaa, bbb),new google.maps.LatLng(xxx, yyy)),
map:map,map2,
fillOpacity: 0,
strokeOpacity: 0,
url: 'http://example3.com',
clickable: true
});

[…..lots more rectangles….]

for ( i = 0; i < rectangles.length; i++ ){google.maps.event.addListener(rectangles[i], 'click', function() {window.location.href = this.url;
});
}

layer.setMap(map);
layer.setMap(map2);
    });
}else {
    alert("Geolocation API is not supported in your browser.");
}

 
 

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T02:08:19+00:00Added an answer on June 16, 2026 at 2:08 am

    This will not work:

    rectangles[0]=new google.maps.Rectangle({
      bounds:new google.maps.LatLngBounds(new google.maps.LatLng(a,b),new google.maps.LatLng(x, y)),
      map:map,map2,
      fillOpacity: 0,
      strokeOpacity: 0,
      url: 'http://example.com',
      clickable: true
    });
    

    You need to create a separate rectangle for each map (the rectangle can only be on one map at a time) something like this (which creates a two dimensional array, [1] for map, [2] for map2):

    rectangles[1][0]=new google.maps.Rectangle({
      bounds:new google.maps.LatLngBounds(new google.maps.LatLng(a,b),new google.maps.LatLng(x, y)),
      map:map,
      fillOpacity: 0,
      strokeOpacity: 0,
      url: 'http://example.com',
      clickable: true
    });
    
    rectangles[2][0]=new google.maps.Rectangle({
      bounds:new google.maps.LatLngBounds(new google.maps.LatLng(a,b),new google.maps.LatLng(x, y)),
      map:map2,
      fillOpacity: 0,
      strokeOpacity: 0,
      url: 'http://example.com',
      clickable: true
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know how can I replace this 2 symbol below from the string
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.