Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support update image #1199

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
7c47e74
fix: can not find path when run script in macOS & nested dart types e…
hungtrn75 Sep 30, 2022
22bbda2
fix: can not sync project
hungtrn75 Sep 30, 2022
28e81ee
feat: support heatmap layer
hungtrn75 Sep 30, 2022
ebbbf54
feat: support heatmap layer
hungtrn75 Sep 30, 2022
57a17a0
feat: support heatmap layer
hungtrn75 Sep 30, 2022
09cfc8e
feat: support heatmap layer
hungtrn75 Sep 30, 2022
607aa41
local pbxproj
hungtrn75 Sep 30, 2022
b72fd72
fix: error when not await future setSymboAllowOverlap in example
hungtrn75 Sep 30, 2022
aa14067
fix: error when not await future setSymboAllowOverlap in example
hungtrn75 Sep 30, 2022
1b502b9
add fill extrusion example
hungtrn75 Sep 30, 2022
4e6a8f5
fix: error generate code swift template with snake case
hungtrn75 Sep 30, 2022
ca88892
migration: edit swift template & add ios rename props
hungtrn75 Sep 30, 2022
955ec99
feat: support fill extrusion layer
hungtrn75 Sep 30, 2022
aa20cbc
ci: run jobs
hungtrn75 Sep 30, 2022
2a6d5a7
docs: support fill extrusion layer
hungtrn75 Sep 30, 2022
85478f5
docs: support fill extrusion layer
hungtrn75 Sep 30, 2022
5942849
refactor codegen
hungtrn75 Oct 1, 2022
dae4450
add update image source example
hungtrn75 Oct 3, 2022
be927b2
feat: update image for image source
hungtrn75 Oct 3, 2022
f23a959
remove xcode teamid
hungtrn75 Oct 3, 2022
806e97b
Merge branch 'flutter-mapbox-gl:master' into master
hungtrn75 Oct 11, 2022
9ea5027
feat: support update image source with remote image
hungtrn75 Oct 11, 2022
97a1b81
add update remote image example
hungtrn75 Oct 11, 2022
132c547
add update remote image example
hungtrn75 Oct 11, 2022
998641a
ci: run jobs
hungtrn75 Oct 11, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
import io.flutter.plugin.platform.PlatformView;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
Expand Down Expand Up @@ -1205,6 +1206,32 @@ public void onFailure(@NonNull Exception exception) {
result.success(null);
break;
}
case "style#updateImage":
{
if (style == null) {
result.error(
"STYLE IS NULL",
"The style is null. Has onStyleLoaded() already been invoked?",
null);
}
ImageSource imageSource = style.getSourceAs(call.argument("imageSourceId"));
List<LatLng> coordinates = Convert.toLatLngList(call.argument("coordinates"), false);
if (coordinates != null) {
// https://github.com/mapbox/mapbox-maps-android/issues/302
imageSource.setCoordinates(
new LatLngQuad(
coordinates.get(0),
coordinates.get(1),
coordinates.get(2),
coordinates.get(3)));
}
String url = call.argument("url");
if (url != null) {
imageSource.setUri(URI.create(url));
}
result.success(null);
break;
}
case "style#addSource":
{
final String id = Convert.toString(call.argument("sourceId"));
Expand Down
2 changes: 1 addition & 1 deletion example/ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>9.0</string>
<string>11.0</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion example/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project
platform :ios, '9.0'
platform :ios, '11.0'
use_frameworks!

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
Expand Down
6 changes: 3 additions & 3 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
Expand Down Expand Up @@ -439,7 +439,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -488,7 +488,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
Expand Down
6 changes: 4 additions & 2 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ import 'page.dart';
import 'place_batch.dart';
import 'place_circle.dart';
import 'place_fill.dart';
import 'place_source.dart';
import 'place_asset_source.dart';
import 'place_remote_source.dart';
import 'place_symbol.dart';
import 'scrolling_map.dart';
import 'sources.dart';
Expand All @@ -37,7 +38,8 @@ final List<ExamplePage> _allPages = <ExamplePage>[
AnimateCameraPage(),
MoveCameraPage(),
PlaceSymbolPage(),
PlaceSourcePage(),
PlaceAssetSourcePage(),
PlaceRemoteSourcePage(),
LinePage(),
LocalStylePage(),
LayerPage(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// found in the LICENSE file.

import 'dart:async';
// ignore: unnecessary_import
import 'dart:typed_data';

import 'package:flutter/material.dart';
Expand All @@ -12,8 +13,8 @@ import 'package:mapbox_gl/mapbox_gl.dart';
import 'main.dart';
import 'page.dart';

class PlaceSourcePage extends ExamplePage {
PlaceSourcePage() : super(const Icon(Icons.place), 'Place source');
class PlaceAssetSourcePage extends ExamplePage {
PlaceAssetSourcePage() : super(const Icon(Icons.place), 'Place asset source');

@override
Widget build(BuildContext context) {
Expand Down
192 changes: 192 additions & 0 deletions example/lib/place_remote_source.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:async';
// ignore: unnecessary_import

import 'package:flutter/material.dart';
import 'package:mapbox_gl/mapbox_gl.dart';

import 'main.dart';
import 'page.dart';

class PlaceRemoteSourcePage extends ExamplePage {
PlaceRemoteSourcePage()
: super(const Icon(Icons.place), 'Place remote source');

@override
Widget build(BuildContext context) {
return const PlaceSymbolBody();
}
}

class PlaceSymbolBody extends StatefulWidget {
const PlaceSymbolBody();

@override
State<StatefulWidget> createState() => PlaceSymbolBodyState();
}

class PlaceSymbolBodyState extends State<PlaceSymbolBody> {
PlaceSymbolBodyState();

static const SOURCE_ID = 'sydney_source';
static const LAYER_ID = 'sydney_layer';

bool sourceAdded = false;
bool layerAdded = false;
late MapboxMapController controller;

void _onMapCreated(MapboxMapController controller) {
this.controller = controller;
}

@override
void dispose() {
super.dispose();
}

/// Adds an remote image as a source to the currently displayed style
Future<void> addImageSourceFromRemote(
String imageSourceId, String url) async {
controller.addSource(
SOURCE_ID,
ImageSourceProperties(url: url, coordinates: [
[151.2288236618042, -33.84322353475214],
[151.19916915893555, -33.84322353475214],
[151.19916915893555, -33.86264728692581],
[151.2288236618042, -33.86264728692581]
]));
}

/// Update an remote image as a source to the currently displayed style
Future<void> updateImageSourceFromRemote(
String imageSourceId, String url) async {
controller.updateImage(
imageSourceId,
url: url,
coordinates: const LatLngQuad(
topLeft: LatLng(-33.89884564291081, 151.25229835510254),
topRight: LatLng(-33.89884564291081, 151.20131492614746),
bottomRight: LatLng(-33.934601369931634, 151.20131492614746),
bottomLeft: LatLng(-33.934601369931634, 151.25229835510254),
),
);
}

Future<void> removeImageSource(String imageSourceId) {
return controller.removeSource(imageSourceId);
}

Future<void> addLayer(String imageLayerId, String imageSourceId) {
if (layerAdded) {
removeLayer(imageLayerId);
}
setState(() => layerAdded = true);
return controller.addLayer(imageSourceId, imageLayerId,
RasterLayerProperties(rasterFadeDuration: 0));
}

Future<void> addLayerBelow(
String imageLayerId, String imageSourceId, String belowLayerId) {
if (layerAdded) {
removeLayer(imageLayerId);
}
setState(() => layerAdded = true);
return controller.addLayer(imageSourceId, imageLayerId,
RasterLayerProperties(rasterFadeDuration: 0),
belowLayerId: belowLayerId);
}

Future<void> removeLayer(String imageLayerId) {
setState(() => layerAdded = false);
return controller.removeLayer(imageLayerId);
}

@override
Widget build(BuildContext context) {
return Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
SizedBox(
height: 300.0,
child: MapboxMap(
accessToken: MapsDemo.ACCESS_TOKEN,
onMapCreated: _onMapCreated,
initialCameraPosition: const CameraPosition(
target: LatLng(-33.852, 151.211),
zoom: 10.0,
),
),
),
Expanded(
child: SingleChildScrollView(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Column(
children: <Widget>[
TextButton(
child: const Text('Add source (remote image)'),
onPressed: sourceAdded
? null
: () {
addImageSourceFromRemote(SOURCE_ID,
'https://media-cdn.tripadvisor.com/media/photo-s/03/9b/2e/15/sydney.jpg')
.then((value) {
setState(() => sourceAdded = true);
});
},
),
TextButton(
child: const Text('Update source (remote image)'),
onPressed: !sourceAdded
? null
: () {
updateImageSourceFromRemote(SOURCE_ID,
'https://media.istockphoto.com/photos/view-of-sydney-harbour-australia-picture-id535455441?k=20&m=535455441&s=612x612&w=0&h=9eDvK_3h-KKHJEOLlOL2kFxtg0y95MXacEyFpHzu-9s=')
.then((value) {
setState(() => sourceAdded = true);
});
},
),
TextButton(
child: const Text('Remove source (remote image)'),
onPressed: sourceAdded
? () async {
await removeLayer(LAYER_ID);
removeImageSource(SOURCE_ID).then((value) {
setState(() => sourceAdded = false);
});
}
: null,
),
TextButton(
child: const Text('Show layer'),
onPressed: sourceAdded
? () => addLayer(LAYER_ID, SOURCE_ID)
: null,
),
TextButton(
child: const Text('Show layer below water'),
onPressed: sourceAdded
? () => addLayerBelow(LAYER_ID, SOURCE_ID, 'water')
: null,
),
TextButton(
child: const Text('Hide layer'),
onPressed:
sourceAdded ? () => removeLayer(LAYER_ID) : null,
),
],
),
],
),
),
),
],
);
}
}
14 changes: 1 addition & 13 deletions example/macos/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@
33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; };
33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; };
33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; };
33D1A10422148B71006C7A3E /* FlutterMacOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 33D1A10322148B71006C7A3E /* FlutterMacOS.framework */; };
33D1A10522148B93006C7A3E /* FlutterMacOS.framework in Bundle Framework */ = {isa = PBXBuildFile; fileRef = 33D1A10322148B71006C7A3E /* FlutterMacOS.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
D73912F022F37F9E000D13A0 /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D73912EF22F37F9E000D13A0 /* App.framework */; };
D73912F222F3801D000D13A0 /* App.framework in Bundle Framework */ = {isa = PBXBuildFile; fileRef = D73912EF22F37F9E000D13A0 /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand All @@ -49,8 +45,6 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
D73912F222F3801D000D13A0 /* App.framework in Bundle Framework */,
33D1A10522148B93006C7A3E /* FlutterMacOS.framework in Bundle Framework */,
);
name = "Bundle Framework";
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -69,22 +63,18 @@
33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Debug.xcconfig"; sourceTree = "<group>"; };
33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Release.xcconfig"; sourceTree = "<group>"; };
33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "Flutter-Generated.xcconfig"; path = "ephemeral/Flutter-Generated.xcconfig"; sourceTree = "<group>"; };
33D1A10322148B71006C7A3E /* FlutterMacOS.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = FlutterMacOS.framework; path = Flutter/ephemeral/FlutterMacOS.framework; sourceTree = SOURCE_ROOT; };
33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = "<group>"; };
33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = "<group>"; };
33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = "<group>"; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = "<group>"; };
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = "<group>"; };
D73912EF22F37F9E000D13A0 /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/ephemeral/App.framework; sourceTree = SOURCE_ROOT; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
33CC10EA2044A3C60003C045 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
D73912F022F37F9E000D13A0 /* App.framework in Frameworks */,
33D1A10422148B71006C7A3E /* FlutterMacOS.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -138,8 +128,6 @@
33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */,
33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */,
33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */,
D73912EF22F37F9E000D13A0 /* App.framework */,
33D1A10322148B71006C7A3E /* FlutterMacOS.framework */,
);
path = Flutter;
sourceTree = "<group>";
Expand Down Expand Up @@ -260,7 +248,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename\n";
shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh embed\n";
};
33CC111E2044C6BF0003C045 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
Expand Down
Loading