Bing Maps - Elektromann/yii2-openlayers-maps GitHub Wiki

Get api key
To use Bing Maps, you need to register and asks api key. To have key visit the Bing Maps site.
After logging in, choose "My Keys" from the "My account" menu. Here you can see your own keys or create a new.
If you have a key, just click on the "Show key", and copy the api key.
Set api key for the widget
You can enter the key in two ways.
1st
When you create a map, add key to the "type" option. It is good way, if you has one map.
<?= \elektromann\openlayers\Map::widget([
'center' => "London",
'type' => [
elektromann\openlayers\Map::TYPE_BINGMAPS,
'apiKey' => 'Your api key here',
],
]); ?>
2nd
You can enter key by component. For many maps this is a good way.
Put this into the yii config file.
'components' => [
'OpenLayersComponent' => [
'class' => \elektromann\openlayers\OpenLayersComponent::className(),
'bingMapsKey' => "Your api key here",
],
//...
]
Show Bing Maps
By default the widget shows Bing Maps "Aerial with labels" type.

<?= \elektromann\openlayers\Map::widget([
'center' => "London",
'type' => [
elektromann\openlayers\Map::TYPE_BINGMAPS,
'apiKey' => 'Your api key here',
],
]); ?>
or
<?= \elektromann\openlayers\Map::widget([
'center' => "London",
'type' => elektromann\openlayers\Map::TYPE_BINGMAPS,
]); ?>
Map types
By default the widget shows Bing Maps "Aerial with labels" type, but you can select an other. You need set mapType.
Map types are:
- Road
- RoadOnDemand
- Aerial
- AerialWithLabels
- ordnanceSurvey
Example ordnanceSurvey map type:
<?= \elektromann\openlayers\Map::widget([
'center' => "London",
'type' => [
elektromann\openlayers\Map::TYPE_BINGMAPS,
'mapType' => "ordnanceSurvey",
],
]); ?>