position.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /* @var $this yii\web\View */
  3. $this->title = '房屋位置';
  4. use yii\helpers\Url;
  5. ?>
  6. <head>
  7. <meta charset="UTF-8">
  8. <title>位置</title>
  9. <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
  10. <link rel="stylesheet" href="http://cache.amap.com/lbs/static/main1119.css"/>
  11. <script type="text/javascript" src="http://webapi.amap.com/maps?v=1.3&key=210550b67bddb270e575a1838060f8ec&plugin=AMap.Autocomplete,AMap.PlaceSearch"></script>
  12. </head>
  13. <body>
  14. <div id="container" tabindex="0"></div>
  15. <script type="text/javascript">
  16. //基本地图加载
  17. var map = new AMap.Map("container", {
  18. resizeEnable: true,
  19. center: [<?=!empty($model->longitude)?$model->longitude:""?>,<?=!empty($model->latitude)?$model->latitude:""?>],//地图中心点
  20. zoom: 15 //地图显示的缩放级别
  21. });
  22. //添加点标记,并使用自己的icon
  23. new AMap.Marker({
  24. map: map,
  25. position: [<?=!empty($model->longitude)?$model->longitude:""?>,<?=!empty($model->latitude)?$model->latitude:""?>],
  26. icon: new AMap.Icon({ //自定义图标
  27. size: new AMap.Size(50, 50), //图标大小
  28. image: "/images/gd-icon.png"
  29. })
  30. });
  31. </script>