How to implement the H5 map app

Source: Internet
Author: User

Point Marker location Display

Usually we use the marker point to calibrate the position, so Jsapi provides a markonamap method in the marker class that accepts a JSON object parameter that contains the position and name two properties, After the tune-up will display the corresponding marker point in the Gold Map client or the Web site tag, based on the marker point display, the user can then use the peripheral search, route planning and navigation functions. Scan the QR code on the right, and click on the marker point in the map to see the effect of moving side.

Core code:

var marker = New amap.marker ({
position:[116.473188,39.993253]
});

Marker.markonamap ({
Position:marker.getPosition (),
Name: ' First open square '//'Name ' property is active on the mobile side
})

All source code, can be copied directly after use:

<! DOCTYPE html>

<meta charset= "Utf-8" >
<meta http-equiv= "x-ua-compatible" content= "Ie=edge" >
<meta name= "viewport" content= "initial-scale=1.0, User-scalable=no, width=device-width" >
<title> Point Markers </title>
<style>
Body, #mapContainer {
margin:0;
height:100%;
width:100%;
font-size:12px;
}
</style>
<link rel= "stylesheet" href= "http://cache.amap.com/lbs/static/main.css?v=1.0?v=1.0"/>
<script src= "Http://cache.amap.com/lbs/static/es5.min.js" ></script>
<script type= "Text/javascript" src= "http://webapi.amap.com/maps?v=1.3&key= the key value you requested &plugin= Amap.toolbar "></script>
<script>
function init () {
Map = new Amap.map ("Mapcontainer", {
Zoom:18,
CENTER:[116.473188,39.993253]
});
Marker = new Amap.marker ({
Map:map,
POSITION:[116.473188,39.993253]
})
Marker.setlabel ({
Offset:new Amap.pixel (20, 20),//modify the label's position relative to the maker
Content: "Click Marker to open the map of Gao de"
});
Marker.on (' click ', Function (e) {
Marker.markonamap ({
Name: ' First Open square ',
Position:marker.getPosition ()
})
})
Map.addcontrol (New Amap.toolbar ());
if (AMap.UA.mobile) {
document.getElementById (' Button_group '). style.display= ' None ';
}
}
</script>

<body onload= "init ()" >
<div id= "Mapcontainer" ></div>
<div class= "Button-group" id= ' button_group ' style= ' Top:15px;bottom:inherit ' >

<div class= ' button ' style= ' Text-align:center ' > Mobile phone sweep code Open demo</div>
</div>
</body>

How to implement the H5 map app

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.