Advertisement
Guest User

Untitled

a guest
Oct 27th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. <?php
  2. //
  3. // ext is your protected.extensions folder
  4. // gmaps means the subfolder name under your protected.extensions folder
  5. //
  6. Yii::import('ext.gmap.*');
  7.  
  8. $gMap = new EGMap();
  9. $gMap->zoom = 10;
  10. $mapTypeControlOptions = array(
  11. 'position'=> EGMapControlPosition::LEFT_BOTTOM,
  12. 'style'=>EGMap::MAPTYPECONTROL_STYLE_DROPDOWN_MENU
  13. );
  14.  
  15. $gMap->mapTypeControlOptions= $mapTypeControlOptions;
  16.  
  17. $gMap->setCenter(39.721089311812094, 2.91165944519042);
  18.  
  19. // Create GMapInfoWindows
  20. $info_window_a = new EGMapInfoWindow('<div>I am a marker with custom image!</div>');
  21. $info_window_b = new EGMapInfoWindow('Hey! I am a marker with label!');
  22.  
  23. $icon = new EGMapMarkerImage("http://google-maps-icons.googlecode.com/files/gazstation.png");
  24.  
  25. $icon->setSize(32, 37);
  26. $icon->setAnchor(16, 16.5);
  27. $icon->setOrigin(0, 0);
  28.  
  29. // Create marker
  30. $marker = new EGMapMarker(39.721089311812094, 2.91165944519042, array('title' => 'Marker With Custom Image','icon'=>$icon));
  31. $marker->addHtmlInfoWindow($info_window_a);
  32. $gMap->addMarker($marker);
  33.  
  34. // Create marker with label
  35. $marker = new EGMapMarkerWithLabel(39.821089311812094, 2.90165944519042, array('title' => 'Marker With Label'));
  36.  
  37. $label_options = array(
  38. 'backgroundColor'=>'yellow',
  39. 'opacity'=>'0.75',
  40. 'width'=>'100px',
  41. 'color'=>'blue'
  42. );
  43.  
  44. /*
  45. // Two ways of setting options
  46. // ONE WAY:
  47. $marker_options = array(
  48. 'labelContent'=>'$9393K',
  49. 'labelStyle'=>$label_options,
  50. 'draggable'=>true,
  51. // check the style ID
  52. // afterwards!!!
  53. 'labelClass'=>'labels',
  54. 'labelAnchor'=>new EGMapPoint(22,2),
  55. 'raiseOnDrag'=>true
  56. );
  57.  
  58. $marker->setOptions($marker_options);
  59. */
  60.  
  61. // SECOND WAY:
  62. $marker->labelContent= '$425K';
  63. $marker->labelStyle=$label_options;
  64. $marker->draggable=true;
  65. $marker->labelClass='labels';
  66. $marker->raiseOnDrag= true;
  67.  
  68. $marker->setLabelAnchor(new EGMapPoint(22,0));
  69.  
  70. $marker->addHtmlInfoWindow($info_window_b);
  71.  
  72. $gMap->addMarker($marker);
  73.  
  74. // enabling marker clusterer just for fun
  75. // to view it zoom-out the map
  76. $gMap->enableMarkerClusterer(new EGMapMarkerClusterer());
  77.  
  78. $gMap->renderMap();
  79. ?>
  80. <style type="text/css">
  81. .labels {
  82. color: red;
  83. background-color: white;
  84. font-family: "Lucida Grande", "Arial", sans-serif;
  85. font-size: 10px;
  86. font-weight: bold;
  87. text-align: center;
  88. width: 40px;
  89. border: 2px solid black;
  90. white-space: nowrap;
  91. }
  92. </style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement