论坛

Baidu Maps Custom Maps?

DanTheMan (620 posts) • 0

Google makes it so insanely easy to make a custom map such as this...

mapsengine.google.com/map/edit?mid=zYa43TnHcCpg.kE2UAv9pxE8I

...and embed it into a website.

Alas, this doesn't work well or at all for users inside of China. Does anybody know if there is a simple way to do something similar in Baidu? I just want a map with custom location/description markers that I can embed in my website (or failing that, even an external link would be ok.)

Any ideas much appreciated!

DanTheMan (620 posts) • 0

Yes, WordPress, but the only plugin I found didn't work. For Google it's easy, they just provide a chunk of code to paste into the CMS.

bluppfisk (398 posts) • 0

Hi Dan,

I had a look for you. Looks like it's going to be a pain in the ass: you'll have to get acquainted with Baidu Maps' JavaScript API which is only documented in Chinese:

developer.baidu.com/map/jsdevelop-9.htm

I'm unfortunately on a bike trip so I can't help out, but it doesn't seem too hard. in short:

1 you call the javascript API through the HTML script tag
2 create a new BMap() instance
3 choose a point(x,y) and center and zoom through centerAndZoom(point, zoom)
4 add any controls through addControl(control)
5 create a marker for each of your point through marker(point, icon, label)

the latter is a bit complicated as the label can contain all kinds of information.

Have a look here for an example:

blog.csdn.net/etmanwenhan/article/details/12055555

Or here, in combination with a MySQL database with marker points:

www.cnblogs.com/milkmap/archive/2011/08/16/2135323.html

Don't forget to request your own API key, of course!

If you don't feel like digging through the manual though, why not use google.cn instead? It loads quickly and perfectly within China PRC and outside.

bluppfisk (398 posts) • 0

Are you sure the Baidu Plugin for Wordpress doesn't work, by the way? I didn't get my API key yet so I can't verify, but it looks pretty legit.

When I have a better internet connection, I'll be happy to look at the plugin software.

Vernchiqui (1 post) • 0

I see there have been some changes to google.cn since this last post. Still trying to figure this out myself. Just getting an API from Baidu seems laborious. Is there a not so time consuming way to simply embed a Baidu map on a website?

neddy (277 posts) • 0

Vernchiqui, I am not sure if you are coding a website, or using something like Wordpress (I use Wordpress), but yes, it is a bit of a hassle. You have to register a Baidu account, then register a Developer's account, then "Create an application", then get your API key there. Then, if you are coding manually, you have to use a specia lBaidu-version of Javascript. If you are using Wordpress, you can use php or a plugin.

MonExodus (11 posts) • 0

I am pretty sure that you can get Baidu map to work in your case as long as you can debug the existing plugin(if you are using WP). Baidu has the API out there for this kind of basic application.

Given your map application is not demanding, you can consider www.openstreetmap.com, which I just found not yet blocked, as an alternative. You won't have the language problem with OSM. Plus, it has the wordpress plugin, wordpress.org/plugins/osm/, if you are using WP.

I personally use google map only, FYI.

neddy (277 posts) • 0

I have been fiddling with this all day. The Wordpress plugins really do not work (both of them). It will require manual coding. Another option is to take a screenshot of the map you want and upload it as an image on your site. It is not as interactive and fancy, but it is still useful.

Related forum threads

Login to post