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

  • Home
  • SEARCH
  • 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 9132909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:23:42+00:00 2026-06-17T08:23:42+00:00

I have the following code: <?php if($_GET[‘postcode’]){ ?> //alert(<?php echo $_GET[‘postcode’];?>) <?php }?> function

  • 0

I have the following code:

<?php if($_GET['postcode']){ ?>

//alert(<?php echo $_GET['postcode'];?>)

<?php }?>

      function initialize() {
        var mapOptions = {
          zoom: 6,
          center: new google.maps.LatLng("<?php echo $_GET['postcode'];?>"),
          mapTypeId: google.maps.MapTypeId.ROADMAP
        };

        var map = new google.maps.Map(document.getElementById('map_canvas'),mapOptions);
        map.setTilt(45);

        var addressArray = new Array("<?php echo $_GET['postcode'];?>");
        var geocoder = new google.maps.Geocoder();

        var markerBounds = new google.maps.LatLngBounds();

        for (var i = 0; i < addressArray.length; i++) {
        geocoder.geocode( { 'address': addressArray[i]}, function(results, status) {
        if (status == google.maps.GeocoderStatus.OK) {

        var contentString = '<div id="content">'+
        '<div id="siteNotice">'+
        '</div>'+
        '<h4 id="firstHeading" class="firstHeading">HELLO</h4>'+
        '<div id="bodyContent">'+
        '<p><b>Hello!!</b>' + <?php echo $_GET["order_id"];?> + '</p>'+
        '</div>'+
        '</div>';

        var infowindow = new google.maps.InfoWindow({
        content: contentString
        });

        var marker = new google.maps.Marker({
        map: map, 
        title:"Order Number",
        position: results[0].geometry.location
        });

        markerBounds.extend(results[0].geometry.location);
        map.fitBounds(markerBounds);

        google.maps.event.addListener(marker, 'click', function() {
        infowindow.open(map,marker);
        });

        } else {
        alert("Geocode was not successful for the following reason: " + status);
        }
        });
        }
      }

      function loadScript() {
        var script = document.createElement('script');
        script.type = 'text/javascript';
        script.src = 'https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&' +
            'callback=initialize';
        document.body.appendChild(script);
      }

      window.onload = loadScript;
    </script>

For some reason, when the map loads up, the zoom level is full, so its zoomed right into the marker. I’ve tried adjusting the zoom level on the initialize section, but I have had no joy. My guess is, that it has something to do with the marker bounds. Anyone know how to adjust the zoom so that it is not fully zoomed on the marker?

  • 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-17T08:23:43+00:00Added an answer on June 17, 2026 at 8:23 am

    for some reason, when the map loads up, the zoom level is full, so its zoomed right into the
    marker.

    If you have a bounds object with one LatLng in it, it should zoom in as far as possible. From the documentation:

    fitBounds(bounds:LatLngBounds)  None    Sets the viewport to contain the given bounds.
    

    If you only have one marker, don’t use fitBounds, use .setCenter (on the coordinates of the marker, .setZoom (to your desired zoom level).

    If your code needs to handle both cases (one marker or several markers), count the markers you add to the bounds, if the number is one use .setCenter/.setZoom, if it is more than one, use .fitBounds.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following PHP code: <?php if(isset($_GET['article'])) { echo <b>success</b>; } ?> And
i have the following code : <input type=text value=<?php echo $_GET['msg']; ?>> This input
I have the following code $.when(tableInsert(index.php/get/sync/riesgos, insert_riesgo, evalua.webdb.db, callback)).then(function(){ update_records(riesgos); $.when(tableInsert(index.php/get/sync/estancias, insert_estancia, evalua.webdb.db, callback)).then(function(){
In my page I have the following code hostadd.php <script language=javascript type=text/javascript> function getXMLHTTP()
I have the following PHP code: //switch if (isset($_GET['pg'])) $pg = $_GET['pg']; else{ $pg
I have the following PHP code; <?php component_customer_init(); component_customer_go(); function component_customer_init() { $customer =
I have tried as following code in wordpress inside single.php file <?php echo $counter
I have following code: var params = { cache:false, dataType:json, type:GET, url: /order.php, error:
I have the following source code session1.php <?php session_start(); echo session_id(); ?> session2.php <?php
i have following php code which display company logo <?php $key=$_GET['key']; /// key process

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.