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