Ecshop is added to Baidu Map and supports peripheral tag instances.

Source: Internet
Author: User

Ecshop is added to the Baidu map interface. First, add the following section on the page you want to call (the style can be adjusted by yourself) and pass in the default value, longitude, latitude, and keywords (you can mark the location related to your keyword in the map range ).

The code is as follows: Copy code

<Ul>


<Li onclick = "reload_map ({$ room. Longpolling}, {$ room. latitude}, 'Bus Stop ')" class = "current"> bus </li>

<Li onclick = "reload_map ({$ room. Longpolling}, {$ room. latitude}, 'Subway station ')"> subway </li>

<Li onclick = "reload_map ({$ room. Longpolling}, {$ room. latitude}, 'Lihua Hotel ')"> nearby Lihua </li>

<Li onclick = "reload_map ({$ room. Longpolling}, {$ room. latitude}, 'travel ')"> Tourism </li>

<Li onclick = "reload_map ({$ room. Longwheel}, {$ room. latitude}, 'Restaurant ')"> catering </li>

<Li onclick = "reload_map ({$ room. Longpolling}, {$ room. latitude}, 'shopping ')"> Shopping </li>

<Li onclick = "reload_map ({$ room. Longpolling}, {$ room. latitude}, 'enter')"> Entertainment </li>

<Li onclick = "reload_map ({$ room. Longpolling}, {$ room. latitude}, 'health')"> Healthcare </li>

<Li onclick = "reload_map ({$ room. Longpolling}, {$ room. latitude}, 'bank')"> Bank </li>

</Ul>

<Iframe src = "hotels_map.php? Weidu = {$ room. latitude} & jingdu = {$ room. longpolling} & keywords = bus stop "width =" 752 "height =" 389 "id =" map_iframe "> </iframe>

 


<Script type = "text/javascript">

// Map

Function reload_map (jingdu, weidu, keywords ){

Var url = "hotels_map.php? Weidu = "+ weidu +" & jingdu = "+ jingdu +" & keywords = "+ keywords;

$ ("# Map_iframe"). attr ("src", url );

}

</Script>


In this way, you can switch between different tabs to view the content of different maps.

 

 

 

S_s_map.php:

The code is as follows: Copy code

 


<? Php

 


$ Weidu = $ _ REQUEST ['weidu'];

$ Jingdu = $ _ REQUEST ['jingdu'];

$ Keywords = $ _ REQUEST ['keyword'];

 


If ($ keywords = 'Unilever hotel '){

$ Suofang = 11;

} Else {

$ Suofang = 14;

}

 


$ Str = '

<Head>

<Meta http-equiv = "Content-Type" content = "text/html; charset = utf-8"/>

<Meta name = "viewport" content = "initial-scale = 1.0, user-scalable = no"/>

<Style type = "text/css">

Body, # allmap {width: 100%; height: 100%; overflow: hidden; margin: 0 ;}

</Style>

<Script type = "text/javascript" src = "http://api.map.baidu.com/api? V = 2.0 & ak = your key (you can apply for it easily) "> </script>

<Script type = "text/javascript" src = "http://developer.baidu.com/map/jsdemo/demo/convertor.js"> </script>

<Title> Search by central point keyword </title>

</Head>

<Body>

<Div id = "allmap"> </div>

</Body>

</Html>

<Script type = "text/javascript">

// Convert Google coordinates to Baidu coordinates

Var xx = '. $ jingdu .';

Var yy = '. $ weidu .';

Var ggPoint = new BMap. Point (xx, yy );

 


// Callback function after coordinate transformation

TranslateCallback = function (point ){

// Alert (point. lng + "," + point. lat );

Var map = new BMap. Map ("allmap"); // create a Map instance

Map. centerAndZoom (new BMap. Point (point. lng, point. lat), '. $ suofang.'); // you can set the center Point and map zoom level when initializing.

Var local = new BMap. LocalSearch (map ,{

RenderOptions: {map: map, autoViewport: true}

});

Map. addControl (new BMap. ScaleControl ());

Map. enableScrollWheelZoom (true );

Map. addControl (new BMap. NavigationControl (); // add the default zoom/pan control

Var point = new BMap. Point (point. lng), (point. lat ));

Map. centerAndZoom (point, '. $ suofang .');

Var marker = new BMap. Marker (point); // create annotation

Map. addOverlay (marker); // add the annotation to the map

Marker. setAnimation (BMAP_ANIMATION_BOUNCE); // specifies the animation that exists.

 


// Visual range search

Var local = new BMap. LocalSearch (map ,{

RenderOptions: {map: map}

});

Local. searchInBounds ("'. $ keywords.'", map. getBounds ());

}

 


SetTimeout (function (){

BMap. Convertor. translate (ggPoint, 2, translateCallback); // Convert the GCJ-02 coordinates to Baidu coordinates

},300 );

 


</Script> ';

 


Echo $ str;

 


?>


 

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.