PHP code example of rainsens / map

1. Go to this page and download the library: Download rainsens/map library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

rainsens / map example snippets


use Rainsens\Map\Map;
$key = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$map = new Map($key);

$map->GeoCode->get('北京市朝阳区阜通东大街6号', '北京');
$map->GeoCode->get('北京市朝阳区阜通东大街6号', '北京', 'json');
$map->GeoCode->get('北京市朝阳区阜通东大街6号', '北京', 'xml');

$cities = [
    '北京市朝阳区阜通东大街6号',
    '北京市通州区运河东大街6号',
];

$map->GeoCode->get($cities, '北京');

"status": "1",
"info": "OK",
"infocode": "10000",
"count": "1",
"geocodes": [
    {
        "formatted_address": "北京市朝阳区阜通东大街|6号",
        "country": "中国",
        "province": "北京市",
        "citycode": "010",
        "city": "北京市",
        "district": "朝阳区",
        "township": [],
        "neighborhood": {
            "name": [],
            "type": []
        },
        "building": {
            "name": [],
            "type": []
        },
        "adcode": "110105",
        "street": "阜通东大街",
        "number": "6号",
        "location": "116.483038,39.990633",
        "level": "门牌号"
    }
]

<response>
    <status>1</status>
    <info>OK</info>
    <infocode>10000</infocode>
    <count>1</count>
    <geocodes type="list">
        <geocode>
            <formatted_address>北京市朝阳区阜通东大街|6号</formatted_address>
            <country>中国</country>
            <province>北京市</province>
            <citycode>010</citycode>
            <city>北京市</city>
            <district>朝阳区</district>
            <township></township>
            <neighborhood>
                <name></name>
                <type></type>
            </neighborhood>
            <building>
                <name></name>
                <type></type>
            </building>
            <adcode>110105</adcode>
            <street>阜通东大街</street>
            <number>6号</number>
            <location>116.483038,39.990633</location>
            <level>门牌号</level>
        </geocode>
    </geocodes>
</response>

$map->geoFence()->create([...]);
$map->geoFence()->search([...]);
$map->geoFence()->update([...]);
$map->geoFence()->enable(string $gid, bool $status = true);
$map->geoFence()->delete(string $gid);
$map->geoFence()->monitor([...]);

    .
    .
    .
     'map' => [
        'key' => env('MAP_API_KEY'),
    ],

MAP_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Map::geoCode->get('北京市朝阳区阜通东大街6号', '北京');

Map::geoFence()->create([...]);
Map::geoFence()->search([...]);
Map::geoFence()->update([...]);
Map::geoFence()->enable(string $gid, bool $status = true);
Map::geoFence()->delete(string $gid);
Map::geoFence()->monitor([...]);