Question:

where to get web page map script?

by Guest3090  |  11 years, 6 month(s) ago

0 LIKES UnLike

I am creating some WebPages and I need to put Google maps in the WebPages. Someone please tell me the web page map script.

 Tags: map, page, Script, Web

   Report

1 ANSWERS

  1. Guest5445

    First of all open the web page of your website and then insert the following two lines to the <head> of your document.

    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />

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

    You also need google APIs. For that you need to to sign up for an API key. It costs nothing, and it allows Google to contact you directly if they find an issue with your site.

    You also need to do other than just installing the Maps API.  You have to add some settings and also define your map on the page. In the <head> of your document yadu will insert the following script:

    <script type="text/javascript">

    function initialize() {

    var latlng = new google.maps.LatLng(40.7562008,-73.9903784);

    var myOptions = {

    zoom: 18,

    center: latlng,

    mapTypeId: google.maps.MapTypeId.ROADMAP

    };

    var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

    }

    </script>

    Change the part (google.maps.LatLng(40.7562008,-73.9903784))to the latitude and longitude numbers.


    Once you have done all, the script elements inserted to the <head> of your document, now you require to position your map on the page. You can do it by placing a <div> with the id="map_canvas"attribute. I suggest you also style this div with the width and height that will fit on your page:

    <div id="map_canvas_sat" style="width:300px; height:300px;"></div>

    Finally you need to get your map to display is to run the script when the browser loads the page. place this to your <body> tag:

    <body onload="initialize()">

     

Sign In or Sign Up now to answser this question!

Question Stats

Latest activity: 11 years, 8 month(s) ago.
This question has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.
Unanswered Questions