[Filled pit debugging Series _uniapp articles] high moral map using the JS API introduced

Maps JS API Quick Start official website link

Initialization location problem

Do not be initialized onshow, onLoad in synchronization introduced api (map will not see for a long time effect, the certified results can not see), mounted in the recommended initialization.


Cannot read property ‘push’ of undefined 错误


The above error will occur in accordance with the following lines

		mounted() {
			var map = new AMap.Map('map_container', {
				zoom: 12,
				center: [120 31],
				layers: [
					new AMap.Marker({position: [120, 31]}),
				],
			});
		}

The above wording to read:

	mounted() {
			var map = new AMap.Map('map_container', {
				zoom: 12,
				center: [120, 31],
			});
			var marker = new AMap.Marker({
				position: [120, 31]
			})
			map.add(marker);
		},

This will not go wrong!

Released nine original articles · won praise 4 · Views 3749

Guess you like

Origin blog.csdn.net/qq_38868135/article/details/98593784