1. ホーム
  2. Web制作
  3. HTML/Xhtml

HTMLページのジャンプとパラメータ渡しの問題

2022-01-08 18:21:51

HTMLページがジャンプする

http://lbs.amap.com/api/android-sdk/guide/create-map/show-map

第2パラメータ self, 現在のウィンドウで開く場合; _blank (デフォルト), 別の新しいウィンドウで開く場合。

http://lbs.amap.com/api/android-sdk/guide/create-map/mylocation

HTMLのパラメータ受け渡し。

1.URLパスの参照。

最初のページ(a.html)です。

// Set the location listener
aMap.setLocationSource(this);
// set to true to show the location layer and trigger location, false to hide the location layer and not trigger location, default is false
aMap.setMyLocationEnabled(true);
// Set the location type to location mode, there are several types of location, follow or map rotation according to orientation
aMap.setMyLocationType(AMap.LOCATION_TYPE_LOCATE);

2ページ目(b.html)です。

// Set the location listener
aMap.setLocationSource(this);
// set to true to show the location layer and trigger location, false to hide the location layer and not trigger location, default is false
aMap.setMyLocationEnabled(true);
// Set the location type to location mode, there are several types of location, follow or map rotation according to orientation
aMap.setMyLocationType(AMap.LOCATION_TYPE_LOCATE);

Step 2, initialize the positioning

aMap.setLocationSource(this) contains two callbacks, activate(OnLocationChangedListener) and deactivate().

In activate(), set the location initialization and start the location, and in deactivate(), write the calls related to stopping the location.
Java

OnLocationChangedListener mListener;
AMapLocationClient mlocationClient;
AMapLocationClientOption mLocationOption;
/**
 * Activate the location
 */
@Override
public void activate(OnLocationChangedListener listener) {
    mListener = listener;
    if (mlocationClient == null) {
        //initialize the location
        mlocationClient = new AMapLocationClient(this);
        //initialize location parameters
        mLocationOption = new AMapLocationClientOption();
        //Set the location callback listener
        mlocationClient.setLocationListener(this);
        //set to high accuracy positioning mode
        mLocationOption.setLocationMode(AMapLocationMode.Hight_Accuracy);
        //Set the positioning parameters
        mlocationClient.setLocationOption(mLocationOption);
        // This method will initiate a location request every fixed time, in order to reduce power consumption or network traffic consumption.
        // Be careful to set the appropriate location interval (minimum interval supported is 2000ms), and call the stopLocation() method at the appropriate time to cancel the location request
        // call the onDestroy() method at the appropriate lifecycle after the location is finished
        // In the case of a single location, there is no need to call the stopLocation() method to remove the request whether the location is successful or not, the location sdk will remove it internally
        mlocationClient.startLocation();// start location
    }
}
/**
 * stopLocation
 */
@Override
public void deactivate() {
    mListener = null;
    if (mlocationClient ! = null) {
        mlocationClient.stopLocation();
        mlocationClient.onDestroy();
    }
    mlocationClient = null;
}

注:中国語送信:あなたは、ページaのURLをencodeURIでエンコードし、ページbのURLをdecodeURIでデコードすることができます。

2.Cookieの転送。

/**
 * Callback function after successful location
 */
@Override
public void onLocationChanged(AMapLocation amapLocation) {
    if (mListener ! = null&&amapLocation ! = null) {
        if (amapLocation ! = null
                &&amapLocation.getErrorCode() == 0) {
            mListener.onLocationChanged(amapLocation);// show system small blue dot
        } else {
            String errText = "Location failed," + amapLocation.getErrorCode() + ": " + amapLocation.getErrorInfo();
            Log.e("AmapErr",errText);
        }
    }
}

3. localStorageオブジェクトの参照を渡す。

a.htmlを参照してください。

@Override
protected void onDestroy() {
    super.onDestroy();
    mapView.onDestroy();
    if(null ! = mlocationClient){
        mlocationClient.onDestroy();
    }
}

b.html。

public class MapaActivity extends AppCompatActivity implements LocationSource, AMapLocationListener {
    MapView mMapView = null;
    AMap aMap;
    OnLocationChangedListener mListener;
    AMapLocationClient mlocationClient;
    AMapLocationClientOption mLocationOption;
    private boolean isFirstLoc = true;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_mapa);
        //Get the map control reference
        mMapView = (MapView) findViewById(R.id.map);
        //execute mMapView.onCreate(savedInstanceState) when activity executes onCreate to create the map
        mMapView.onCreate(savedInstanceState);
        //initialize the map controller object
        if (aMap == null) {
            aMap = mMapView.getMap();
            aMap.moveCamera(CameraUpdateFactory.zoomTo(17));
            // Set the location button to be displayed and clickable
            UiSettings settings = aMap.getUiSettings();
            aMap.setLocationSource(this);// set the location listener
            // whether to show the location button
            settings.setMyLocationButtonEnabled(true);
            aMap.setMyLocationEnabled(true);// show location layer and can trigger location, default is flase
        }
        // Set the location listener
        aMap.setLocationSource(this);
        // set to true to show the location layer and can trigger the location, false to hide the location layer and can not trigger the location, the default is false
        aMap.setMyLocationEnabled(true);
        // Set the location type to location mode, there are several types of positioning, following or map rotation according to the orientation
        aMap.setMyLocationType(AMap.LOCATION_TYPE_LOCATE);

    }
    @Override
    protected void onDestroy() {
        super.onDestroy();
        //execute mMapView.onDestroy() when activity executes onDestroy to destroy the map
        mMapView.onDestroy();
        if(null ! = mlocationClient){
            mlocationClient.onDestroy();
        }
    }
    @Override
    protected void onResume() {
        super.onResume();
        //execute mMapView.onResume () when the activity executes onResume to redraw the loaded map
        mMapView.onResume();
    }
    @Override
    protected void onPause() {
        super.onPause();
        //execute mMapView.onPause () when the activity executes onPause to pause the drawing of the map
        mMapView.onPause();
    }
    @Override
    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        //mMapView.onSaveInstanceState (outState) is executed when the activity executes onSaveInstanceState, saving the current state of the map
        mMapView.onSaveInstanceState(outState);
    }
    /**
     * Activate positioning
     */
    @Override
    public void activate(OnLocationChangedListener listener) {
        mListener = listener;
        if (mlocationClient == null) {
            //initialize the location
            mlocationClient = new AMapLocationClient(this);
            //initialize location parameters
            mLocationOption = new AMapLocationClientOption();
            //Set the location callback listener
            mlocationClient.setLocationListener(this);
            //set to high accuracy positioning mode
            mLocationOption.setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy);
            //this method defaults to false, true means locate only once
            mLocationOption.setOnceLocation(true);
        

4. window.opener()

親ページです。

  MyLocationStyle myLocationStyle = new MyLocationStyle();
  myLocationStyle.strokeColor(Color.argb(0, 0, 0, 0));// set the border color of the circle myLocationStyle.radiusFillColor(Color.argb(0, 0, 0, 0));// set the fill color of the circle .
 aMap.setMyLocationStyle(myLocationStyle);
 // Set the zoom level
 aMap.moveCamera(CameraUpdateFactory.zoomTo(17));
 //move the map to the location
 aMap.moveCamera(CameraUpdateFactory.changeLatLng(new LatLng(amapLocation.getLatitude(), amapLocation.getLongitude())));

サブページです。

aMap = mMapView.getMap();
aMap.moveCamera(CameraUpdateFactory.zoomTo(17));
// Set the location button to be displayed and clickable
UiSettings settings = aMap.getUiSettings();
aMap.setLocationSource(this);// set the location listener
// whether to show the location button
settings.setMyLocationButtonEnabled(true);
aMap.setMyLocationEnabled(true);// show location layer and can trigger location, default is flase

概要

以上、HTMLページのジャンプとパラメータ渡しの問題について少し紹介しました、お役に立てれば幸いです、もし何か質問があれば私にメッセージをください、タイムリーに返信します。今後ともスクリプトハウスのホームページをよろしくお願いいたします。