Bloggers recently launched a APP Development , Positioning function is needed , After some tossing , It's finally done , Don't bullshit , The code is as follows

mui.plusReady(function() {
var longitude, latitude;
//var map = new BMap.Map("container"); // navigator.geolocation.getCurrentPosition(function(position) {
// longitude = position.coords.longitude;
// latitude = position.coords.latitude;
//
// console.log("longitude:" + longitude + "==latitude:" + latitude);
// var point = new BMap.Point(longitude, latitude);
// map.centerAndZoom(point, 20); // Initialize map , Set center point coordinates and map level
// var marker = new BMap.Marker(point); // Create annotations
// map.addOverlay(marker); // Add annotations to the map
// map.panTo(point);
// }); plus.geolocation.getCurrentPosition(translatePoint, function(e) {
mui.toast(" abnormal :" + e.message);
}); function translatePoint(position) {
var currentLon = position.coords.longitude;
var currentLat = position.coords.latitude;
var gpsPoint = new BMap.Point(currentLon, currentLat);
BMap.Convertor.translate(gpsPoint, 2, initMap); // Coordinate transformation
} function initMap(point) {
map = new BMap.Map("container"); // Create map
map.addControl(new BMap.NavigationControl());
map.addControl(new BMap.ScaleControl());
map.addControl(new BMap.OverviewMapControl());
map.centerAndZoom(point, 15);
map.addOverlay(new BMap.Marker(point)); } // setTimeout(function() {
// var gpsPoint = new BMap.Point(longitude, latitude);
// BMap.Convertor.translate(gpsPoint, 0, function(point) {
// var geoc = new BMap.Geocoder();
// geoc.getLocation(point, function(rs) {
// var addComp = rs.addressComponents;
// mui.alert(addComp.province + ", " + addComp.city + ", " + addComp.district + ", " + addComp.street + ", " + addComp.streetNumber);
// });
// });
// }, 3000); });

Be careful , In use , Need to introduce Baidu map JS

<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak= developer key"></script>
<script type="text/javascript" src="http://developer.baidu.com/map/jsdemo/demo/convertor.js"></script>

among , developer key Need to go to Baidu map developer platform to apply , Here is a link to http://lbsyun.baidu.com/index.php?title=androidsdk/guide/key

【MUI】 Baidu map positioning function of more related articles

  1. utilize HBuilder Based on Development MUI Of H5+ app Baidu map positioning function is used in

    There are two ways to locate the function : First, initialize the built-in map : var map = new plus.maps.Map("map"); It's yellow here map yes html Inside id: <div id= ...

  2. android Baidu map positioning function is realized

    After a few days , Finally, the positioning function has been realized , It's hard work , There are positioning knowledge and layer knowledge , I'll post the code here , Let's share it . package com.example.foreveross.off ...

  3. MUI frame --- Realize Baidu map positioning function

    1 2 <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak= ...

  4. mui --- How to get Baidu map positioning function

    <!doctype html> <html> <head> <meta charset="UTF-8"> <title> ...

  5. android Baidu Maps Positioning function

    I don't say much nonsense Just create a new one android project :location, And then take a minute to apply for one key, And then it's positioning Baidu demo Just copy it 1: First, in the AndroidManifest.xml Add permissions to <u ...

  6. iOS Third party maps - Baidu map common function use (POI Search for , Geographic positive and negative coding , location , Add labels )

    Baidu map official website : http://developer.baidu.com/map/index.php?title=iossdk Baidu map integration 1. Import correlation package

  7. Baidu map positioning SDK The idea of

    Baidu map positioning Premise Come back from Hong Kong , A surge of blood rose in my heart , Motivate yourself to find the market demand , To start a business , Moving towards the dream . brief introduction Baidu Android location SDK Support Android1.5 And the above equipment , Provide : Positioning function ...

  8. Android Use Baidu map to locate and display the location of the mobile phone, then use the front camera “ Take photoes in secret ”

    Today, the boss asked me to verify the technical feasibility , recorded . demand : Locate the location of the mobile phone and display it on Baidu map , After getting the position, use the front camera to capture When you get this demand , Not familiar with the use of cameras , So I first made a positioning mobile phone and displayed it on Baidu map ...

  9. ( eighteen )WebGIS Design and implementation of empty function and map positioning function in

    The copyright of the article is jointly owned by Li Xiaohui and blog park , If reprint, please indicate the source clearly :http://www.cnblogs.com/naaoveGIS/. 1. background When a lot of elements are added to the map , Different elements need to be controlled , most ...

Random recommendation

  1. Sass Pre one :

    Why use Sass As front-end (html.javascript.css) One of the three carriages of css, Always in static language ,HTML5 The fire has spread all over the country .javascript because NODE.JS And become the current front and rear end unified open ...

  2. qTip2 delicate jQuery Prompt information plug-in

    qTip2 delicate jQuery Prompt information plug-in     Source :http://www.cnblogs.com/lwme/archive/2012/02/16/qtip2-jquery-plugin.html ...

  3. hdu 2102 A plan (BFS, Basics )

    subject // Write it carefully BFS, Focus on # How to deal with it : // It took a few hours to get this simple BFS It's done , I really need to increase my proficiency , Need to be more careful : // The code is a bit messy , But I don't want to change ,,,,, #include& ...

  4. Windows Phone Development (15): resources

    original text :Windows Phone Development (15): resources Movable type printing is one of the key technologies in China " Four great inventions " One of , After Bi Sheng invented movable type printing , He soon discovered a problem , With the increasing number of materials to be printed , There are more and more Chinese characters to use ...

  5. sublime2 nodejs No response to compile

    It's been bothering me for a week , It's not easy to solve , One . Problem description : Install some of the online tutorials in sublime text 2 Inside installation Nodejs Compiler environment for , But after the installation, there is no output to compile , The compilation didn't respond , only ...

  6. Do Now A place for you to study APP—— Team blog

    Do Now A place for you to study APP From the fried dough sticks, only half of the team's wisdom is condensed ! Team blog Directory : The first week of team work Team work week two Do Now -- Team sprint blog one Do-Now- The team Scrum sprint ...

  7. [Swift]LeetCode188. The best time to buy and sell stocks IV | Best Time to Buy and Sell Stock IV

    Say you have an array for which the ith element is the price of a given stock on day i. Design an al ...

  8. HBase Practical cases : The Internet of vehicles monitoring system

    Project background This project is the vehicle network monitoring system , The system consists of on-board hardware equipment . Cloud server is composed of . The on-board hardware equipment will collect all kinds of state information of the vehicle regularly , And upload to the server through the mobile network . When the server receives the data sent by the hardware device, it needs to analyze the data first , check ...

  9. ubuntu root Set up

    ubuntu16.04 Of root The initial password is random , Every time I turn on a new one root password . The specific modification method is :sudo passwd Enter your user name and password root password su root Enter password to log in

  10. JVM Of Client Patterns and Server Pattern

    summary JVM There are two modes of operation Server And Client. The difference between the two models is ,Client Mode starts faster ,Server Mode starts slowly : But after a long period of stable operation Server Mode is faster than Clie ...