Google Maps API V3 development for mobile devices

Source: Internet
Author: User

Development for mobile devices

Google Maps API v3 is designed for fast loading and stable operation on mobile devices. In particular, we have focused on developing advanced mobile devices such as Android and IOS phones. A mobile device has a smaller screen than a traditional browser on a desktop computer. Also, mobile devices often have unique, specific behaviors (such as "two-finger pinch scaling"). If you want your app to run stably on a mobile device, we recommend that you do the following:

    • <div>set the width and Height properties that contain your map to 100% . Note, however, that using these values on some older desktop browsers does not give a good display.
    • You can navigator.userAgent detect IPhone and Android devices by checking the properties in the DOM:
      function Detectbrowser () {    var useragent = navigator.useragent;    var mapdiv = document.getElementById ("Map_canvas");      if (Useragent.indexof (' IPhone ')! =-1 | | useragent.indexof (' Android ')! =-1) {      mapdiv.style.width = ' 100% ';      Mapdiv.style.height = ' 100% ';    } else {      mapdiv.style.width = ' 600px ';      Mapdiv.style.height = ' 800px ';    }  }  
      That way, you can change the layout of a particular device, just as we change the actual area of the screen for each device here.
    • Android and IOS devices will apply the following<meta>Mark:

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

        • This setting specifies that the map should be displayed in full-screen mode, and the user must not adjust the size of the map. Note that you need to add this tag to the elements of your Web page to <meta> use the IPhone's Safari browser.

      For more information on developing for the IPhone, see the Apple developer documentation. For more information on developing for Android devices, see your Android documentation.

      Localization

      You can localize your Google Maps API app by changing the default language settings and setting the area code for your app to change the way your app runs based on a given country or region.

      Language localization

      The Google Maps API uses the browser's preferred language settings when displaying text information, such as control names, copyright notices, driving directions, and labels on a map. In most cases, this is the preferred practice; You should not generally override the user's preferred language settings. However, if you want to change the maps API to ignore the browser's language settings and have the browser display information in a specific language, you can add optional parameters to the tag when you join the Maps API JavaScript code language <script> to specify the language to use.

      For example, to display the Maps API app in Japanese, you can &language=ja add to the <script> tag as follows:

      <script type= "Text/javascript" src= "Http://maps.googleapis.com/maps/api/js?sensor=false&language=ja" >

      Note: After loading the API as described above, the system will display Japanese for all users regardless of user preferences. Before you set this option, make sure that you really want to do this.
      The Maps JavaScript API also supports bidirectional (Bidi) text, which itself contains both left-to-right (LTR) and right-to-left (RTL) language characters. Examples of RTL languages include Arabic, Hebrew, and Persian. In general, you should use thedir=‘rtl‘Added to the Web pageelement to specify the RTL language Web page to render correctly. Regional localization

      By default, the maps API provides map tiles and favors application behavior based on the country/region of the primary domain in which the API is loaded. If you want to change the app to provide different map tiles or biased apps (for example, biased geocoding results closer to an area), you can region <script> override the default behavior by adding parameters to the tag when you join the maps API JavaScript code.

      As a developer of the Maps API app, it is your responsibility to ensure that your application complies with local laws by ensuring correct regional localization for the country in which your app is hosted.

      regionThe parameter accepts a Unicode region sub-tag identifier, which is typically mapped to a one-to-one for the country code top-level domain name (ccTLD). In addition to some notable differences, most Unicode region identifiers are identical to the ISO 3166-1 code. For example, the UK CcTLD is "UK" (corresponding to its domain name .co.uk ) and its region identifier is "GB".

      For example, to use the Maps API app that is localized to the UK, you can &region=GB add it to the <script> markup as follows:

      <script type= "Text/javascript" src= "Http://maps.googleapis.com/maps/api/js?sensor=false?ion=GB" >

      Version control

      The Google maps API team regularly updates this JavaScript API to add new map items, fix bugs, and improve performance. All API changes are backwards compatible to ensure that you are using the current record interface when you launch your app, and that the app can continue to run after the API is updated without modification. ( note : Experimental map items recorded in the experimental API reference are not covered by this warranty.) Experimental map items are explicitly marked in the API documentation. )

      Version type

      You only need to specify the API version using the parameters requested by the Maps JavaScript API bootstrapper v to indicate that you want to load the version in your app. Currently, the system supports the following two options:

        • The release version, which can be v=3 specified using or omitting v parameters.
        • The experimental version, which can be used v=3.exp to specify. This version is the current version based on the backbone version, which contains all the bug fixes and new map items that were publicly released.
        • A numbered version, with v=3.number a representation that specifies the set of map items for the API.

      The following bootstrapper request demonstrates how to request a specific version of the Maps JavaScript API:

      Http://maps.googleapis.com/maps/api/js?v=3.9&sensor=true_or_false


      Each quarter, we build a new numbered version ("release version") and publish it for public use. Throughout the quarter, we will continue to add bug fixes to this release, as well as the maps JavaScript API change log, while ensuring that the set of map itemsets remains stable.

      When we issue a new numbered version, we will "freeze" the previous release, which means we are no longer updating it with any code changes (including bug fixes) to ensure its full stability. Each time we launch a new frozen version in this way, the existing frozen version is deactivated. In other words, we will only provide a frozen version for any given time period. Apps that request a numbered version that has been deactivated will automatically receive the current frozen version.

      Select API version

      When choosing the right API version for your Maps API V3 app, you can refer to the following guidelines:

        • The production app should specify a release version ( v=3 ) or a frozen version. Specifies that a deactivated version (for example v=3.0 ) will always return the current frozen version.
        • The Maps API for business SLA does not apply to the current experimental version. The Maps API for business app must use the current release version (currently 3.9) or an earlier version in order to apply the SLA.
        • When developing the new maps API V3 app, it is recommended that you use the latest experimental version based on the version number (for example, 3.10) until you need to add another map item provided in the newer version to the new version. This way, the version you use will mature as your app is developed, and will become a release version after a period of time, eventually becoming a frozen version.
        • Production apps that request a current frozen version or an earlier version should test the latest release every quarter to identify any problems with backward compatibility before the version freezes.
      Version documentation

      The document will always reflect the experimental version. However, we will provide a separate maintenance reference for each version.

        • Version 3.9 references (release)
        • Version 3.10 Reference (experiment)
        • Version 3.8 Reference (frozen)
        • Versions 3.0 through 3.7 are disabled.
      Troubleshoot problems

      If your code does not work, you can refer to the following methods to resolve the problem you are experiencing:

        • Find spelling errors. Note that the JavaScript language is case sensitive.
        • Use the JavaScript debugger. In Firefox, you can use the JavaScript console, the Venkman debugger, or the Firebug plugin. In IE, you can use Microsoft Script Debugger. This series of screenshots demonstrates how to use a variety of debugging tools.
        • For questions, please post a question on the Google Maps API v3 online forum.
      Last updated February 1, 2013.

Google Maps API V3 development for mobile devices

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.