Supermap uses javascript to mark points on the map. when clicked, a window is displayed.

Source: Internet
Author: User
------- Add a tag on the map. The pop-up window displays the corresponding information. ------ FunctionaddFeature (arr) {Add the element varmarker; for (j0; j & lt; arrlength; j ++) {var ------- to add a flag to the map, click mark. The pop-up window displays the corresponding information. ------ Function addFeature (arr) {// Add the element var marker to the display tag layer; for (j = 0; j // var f = vectorLayer. features [j]; var point = new SuperMap. geometry. point (arr [j] ["site longitude"], arr [j] ["site latitude"]), size = new SuperMap. size (44, 33), offset = new SuperMap. pixel (-(size. w/2),-size. h), icon = new SuperMap. icon ("resource/controlImages/marker.png", size, offset); marker = new SuperMap. marker (new SuperMap. lonLat (point. x, po Int. y), icon); marker. m_RAINSTATION = arr [j]; marker. events. on ({// Method for registering a click event "click": openInfoWin, "scope": marker}); markerLayer. addMarker (marker) ;}}// the pop-up window var infowin = null; function openInfoWin () {// open the form closeInfoWin (); // close the previously opened window. Var marker = this; var lonlat = marker. lonlat; var rainObj = marker. m_RAINSTATION; var contentHTML = ""; contentHTML + = "" + "Site No.:" + rainObj ["Site No."] +"
Site name: "+ rainObj [" site name "] +"
Rainfall: "+ rainObj [" real-time rain "] +"
Time: "+ rainObj [" Update Time "] +"
Site latitude: "+ rainObj [" site latitude "] +"
Site longitude: "+ rainObj [" site longitude "] +"
Unit: "+ rainObj [" unit "] +" "; var size = new SuperMap. size (0, 33); var offset = new SuperMap. pixel (0,-size. h); var icon = new SuperMap. icon ("resource/controlImages/marker.png", size, offset); var popup = new SuperMap. popup. framedCloud ("popwin", new SuperMap. lonLat (lonlat. lon, lonlat. lat), null, contentHTML, icon, true); infowin = popup; map. addPopup (popup);} function closeInfoWin () {// close the window if (infowin) {try {infowin. hide (); // hide the form object infowin. destroy (); // destroy the form object} catch (e ){}}}

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.