Mark the current location and show the footprint on the map

Source: Internet
Author: User

Mark the current location:

ExampleCode:

 
VaRMarker =NewBmap. Marker (point); map. addoverlay (Marker );

 

Show footprints on a map:

To display the footprint list, you must use the "add line" method in Baidu map API.

The reference code provided in the API documentation is:

VaRPolyline =NewBmap. polyline ([NewBmap. Point (116.399, 39.910),NewBmap. Point (116.405, 39.920)], {Strokecolor:& Quot; blue & quot;, strokeweight: 6, strokeopacity: 0.5}); Map. addoverlay (polyline );

We can see that polyline is the key to display discount.

So how to write this Polyline in JSP?

You can use el expressions.

Look at a strange piece of code that the compiler reports an error:

<SCRIPT type = "text/JavaScript"> VaR Map = New Bmap. Map ("position" ); VaR Point = New  Bmap. Point ($ {Currentlocation. longpolling},$ {Currentlocation. Latitude}); Map. centerandzoom (point, 18 );  VaR Polyline = New  Bmap. polyline ([  <C: foreach Items = "$ {list}" Var = "Bean">NewBmap. Point ($ {Bean. longpolling},$ {Bean. Latitude}), </C: foreach> ], {Strokecolor: & Quot; blue & quot;, strokeweight: 6, strokeopacity: 0.5 }); Map. addoverlay (polyline ); </SCRIPT>

We can see that the El expression is actually embedded in the JS Code. This will cause the compiler to report an error. However, this code is valid.

Because the El expression will be organized before JS can run.

If someone else is quoted

"ElThe expression is inServerExecuted, which is sent to the client after the server completes execution,JSYesClientExecuted,El was executed before Js."

Displays the effect of the displayed path.

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.